Zelda Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2023-06-30 09:11:33
Exec Total Coverage
Lines: 12049 19684 61.2%
Functions: 250 350 71.4%
Branches: 10127 21778 46.5%

Line Branch Exec Source
1 //--------------------------------------------------------
2 //--------------------------------------------------------
3 //--------------------------------------------------------
4 // Zelda Classic
5 // by Jeremy Craner, 1999-2000
6 //
7 // hero.cpp
8 //
9 // Hero's class: HeroClass
10 // Handles a lot of game play stuff as well as Hero's
11 // movement, attacking, etc.
12 //
13 //--------------------------------------------------------
14
15 #include <string.h>
16 #include <set>
17
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 #include <stdio.h>
18
19 #include "zc/hero.h"
20 #include "zc/guys.h"
21 #include "subscr.h"
22 #include "zc/zc_subscr.h"
23 #include "zc/decorations.h"
24 #include "gamedata.h"
25 #include "zc/zc_custom.h"
26 #include "zc/title.h"
27 #include "zc/ffscript.h"
28 #include "drawing.h"
29 #include "zc/combos.h"
30 #include "base/zc_math.h"
31 #include "user_object.h"
32 #include "slopes.h"
33 extern FFScript FFCore;
34 extern HeroClass Hero;
35 extern ZModule zcm;
36 extern zcmodule moduledata;
37 extern refInfo playerScriptData;
38 #include "zscriptversion.h"
39 #include "particles.h"
40 #include <fmt/format.h>
41 #include "zc/render.h"
42
43 extern refInfo *ri; //= NULL;
44 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
45 extern portal mirror_portal;
46 using std::set;
47
48 extern int32_t skipcont;
49
50 extern int32_t draw_screen_clip_rect_x1;
51 extern int32_t draw_screen_clip_rect_x2;
52 extern int32_t draw_screen_clip_rect_y1;
53 extern int32_t draw_screen_clip_rect_y2;
54
55 int32_t hero_count = -1;
56 int32_t hero_animation_speed = 1; //lower is faster animation
57 static int32_t z3step = 2;
58 36 static zfix hero_newstep(1.5);
59 36 static zfix hero_newstep_diag(1.5);
60 bool did_scripta=false;
61 bool did_scriptb=false;
62 bool did_scriptl=false;
63 byte lshift = 0;
64 int32_t dowpn = -1;
65 int32_t directItem = -1; //Is set if Hero is currently using an item directly
66 int32_t directItemA = -1;
67 int32_t directItemB = -1;
68 int32_t directItemX = -1;
69 int32_t directItemY = -1;
70 int32_t directWpn = -1;
71 int32_t whistleitem=-1;
72 extern int32_t script_hero_cset;
73
74 void playLevelMusic();
75
76 extern particle_list particles;
77
78 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
79
80 #define CANFORCEFACEUP (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
81 #define NO_GRIDLOCK (get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK)||get_bit(quest_rules, qr_NEW_HERO_MOVEMENT2))
82 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
83 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_bit(quest_rules,qr_BROKEN_Z3_ANIMATION))
84
85 1833 bool item_error()
86 {
87
2/2
✓ Branch 0 taken 1809 times.
✓ Branch 1 taken 24 times.
1833 if(QMisc.miscsfx[sfxERROR])
88 1809 sfx(QMisc.miscsfx[sfxERROR]);
89 1833 return false;
90 }
91 17378907 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
92 {
93
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17378907 times.
17378907 if(check_new_slope(x, y+1, 16, 16, oldx, oldy) < 0) return true;
94 17378907 return false;
95 17378907 }
96
97 5792969 static inline bool platform_fallthrough(bool doslopecheck = true)
98 {
99
3/6
✓ Branch 0 taken 5792969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5792969 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5792969 times.
✗ Branch 5 not taken.
15915245 return (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
100
2/2
✓ Branch 0 taken 731831 times.
✓ Branch 1 taken 731831 times.
5792969 || (getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
101
6/6
✓ Branch 0 taken 4329307 times.
✓ Branch 1 taken 5061138 times.
✓ Branch 2 taken 339327 times.
✓ Branch 3 taken 5453642 times.
✓ Branch 4 taken 311990 times.
✓ Branch 5 taken 27337 times.
1463662 || (Hero.jumping < 0 && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS));
102 }
103
104 static inline bool on_sideview_solid(int32_t x, int32_t y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
105 {
106 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16, (slopesmisc == 3)) < 0) return true;
107 if(slopesmisc == 2) return false;
108 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
109 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
110 if (platform_fallthrough() && !ignoreFallthrough) return false;
111 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16) < 0) return true;
112 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
113 return true;
114 return false;
115 }
116
117 8377116 static inline bool on_sideview_solid_oldpos(int32_t x, int32_t y, int32_t oldx, int32_t oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
118 {
119
3/4
✓ Branch 0 taken 1720286 times.
✓ Branch 1 taken 6656830 times.
✓ Branch 2 taken 1720286 times.
✗ Branch 3 not taken.
8377116 if(slopesmisc != 1 && check_new_slope(x, y+1, 16, 16, oldx, oldy, (slopesmisc == 3)) < 0) return true;
120
2/2
✓ Branch 0 taken 124591 times.
✓ Branch 1 taken 8252525 times.
8377116 if(slopesmisc == 2) return false;
121
4/4
✓ Branch 0 taken 5964910 times.
✓ Branch 1 taken 2287615 times.
✓ Branch 2 taken 171266 times.
✓ Branch 3 taken 5793644 times.
8252525 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
122
6/6
✓ Branch 0 taken 51948 times.
✓ Branch 1 taken 5741696 times.
✓ Branch 2 taken 2120 times.
✓ Branch 3 taken 49828 times.
✓ Branch 4 taken 1445 times.
✓ Branch 5 taken 675 times.
5793644 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
123
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5792969 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5792969 if (platform_fallthrough() && !ignoreFallthrough) return false;
124
3/4
✓ Branch 0 taken 720837 times.
✓ Branch 1 taken 5072132 times.
✓ Branch 2 taken 720837 times.
✗ Branch 3 not taken.
5792969 if (slopesmisc != 1 && check_new_slope(x, y + 1, 16, 16, oldx, oldy) < 0) return true;
125
4/6
✓ Branch 0 taken 1674260 times.
✓ Branch 1 taken 4118709 times.
✓ Branch 2 taken 1674260 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1674260 times.
5792969 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
126 return true;
127 5792969 return false;
128 8377116 }
129
130 void HeroClass::snap_platform()
131 {
132 if(check_new_slope(x, y+1, 16, 16, old_x, old_y, false) < 0)
133 return;
134 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN))
135 {
136 y = 160;
137 return;
138 }
139 if (!(_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)))
140 return;
141 movexy(0,1,false,true,false,false);
142 }
143
144
145 18509046 bool usingActiveShield(int32_t itmid)
146 {
147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18509046 times.
18509046 if(Hero.shieldjinxclk) return false;
148
2/2
✓ Branch 0 taken 2579917 times.
✓ Branch 1 taken 15929129 times.
18509046 switch(Hero.action) //filter allowed actions
149 {
150 case none: case walking: case rafting:
151 case gothit: case swimhit:
152 15929129 break;
153 2579917 default: return false;
154 }
155
3/4
✓ Branch 0 taken 2631 times.
✓ Branch 1 taken 15926498 times.
✓ Branch 2 taken 2631 times.
✗ Branch 3 not taken.
15929129 if(Hero.lift_wpn && (Hero.liftflags&LIFTFL_DIS_SHIELD)) return false;
156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15929129 times.
15929129 if(itmid < 0)
157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15929129 times.
15929129 itmid = (Hero.active_shield_id < 0
158 15929129 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
159
2/2
✓ Branch 0 taken 14451796 times.
✓ Branch 1 taken 1477333 times.
15929129 if(itmid < 0) return false;
160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14451796 times.
14451796 if(item_disabled(itmid)) return false;
161
1/2
✓ Branch 0 taken 14451796 times.
✗ Branch 1 not taken.
14451796 if(!checkitem_jinx(itmid)) return false;
162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14451796 times.
14451796 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
163 if(!isItmPressed(itmid)) return false;
164 return (checkbunny(itmid) && checkmagiccost(itmid));
165 18509046 }
166 11475285 int32_t getCurrentShield(bool requireActive)
167 {
168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11475285 times.
11475285 if(Hero.shieldjinxclk) return -1;
169
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11475285 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11475285 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
170 return Hero.active_shield_id;
171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11475285 times.
11475285 if(!requireActive) return current_item_id(itype_shield);
172 return -1;
173 11475285 }
174 82683 int32_t getCurrentActiveShield()
175 {
176 82683 int32_t id = Hero.active_shield_id;
177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 82683 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
82683 if(id > -1 && usingActiveShield(id))
178 return id;
179 82683 return -1;
180 82683 }
181 6406154 int32_t refreshActiveShield()
182 {
183 6406154 int32_t id = -1;
184
2/2
✓ Branch 0 taken 6228487 times.
✓ Branch 1 taken 177667 times.
6406154 if(DrunkcBbtn())
185 {
186 177667 itemdata const& dat = itemsbuf[Bwpn&0xFFF];
187
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177667 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177667 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
188 {
189 id = Bwpn&0xFFF;
190 }
191 177667 }
192
3/4
✓ Branch 0 taken 6406154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5850548 times.
✓ Branch 3 taken 555606 times.
6406154 if(id < 0 && DrunkcAbtn())
193 {
194 555606 itemdata const& dat = itemsbuf[Awpn&0xFFF];
195
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 555606 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
555606 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
196 {
197 id = Awpn&0xFFF;
198 }
199 555606 }
200
3/4
✓ Branch 0 taken 6406154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6406082 times.
✓ Branch 3 taken 72 times.
6406154 if(id < 0 && DrunkcEx1btn())
201 {
202 72 itemdata const& dat = itemsbuf[Xwpn&0xFFF];
203
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
204 {
205 id = Xwpn&0xFFF;
206 }
207 72 }
208
3/4
✓ Branch 0 taken 6406154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6404997 times.
✓ Branch 3 taken 1157 times.
6406154 if(id < 0 && DrunkcEx2btn())
209 {
210 1157 itemdata const& dat = itemsbuf[Ywpn&0xFFF];
211
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1157 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1157 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
212 {
213 id = Ywpn&0xFFF;
214 }
215 1157 }
216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6406154 times.
6406154 if(!usingActiveShield(id))
217 6406154 return -1;
218 return id;
219 6406154 }
220 static bool is_immobile()
221 {
222 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
223 return false;
224 zfix rate(Hero.steprate);
225 int32_t shieldid = getCurrentActiveShield();
226 if(shieldid > -1)
227 {
228 itemdata const& shield = itemsbuf[shieldid];
229 if(shield.flags & ITEM_FLAG10) //Change Speed flag
230 {
231 zfix perc = shield.misc7;
232 perc /= 100;
233 if(perc < 0)
234 perc = (perc*-1)+1;
235 rate = (rate * perc) + shield.misc8;
236 }
237 }
238 return rate != 0;
239 }
240
241 12859923 bool nomove_action(int action)
242 {
243
2/2
✓ Branch 0 taken 12413650 times.
✓ Branch 1 taken 446273 times.
12859923 switch(action)
244 {
245 case gothit:
246 case drowning:
247 case lavadrowning:
248 case sidedrowning:
249 case falling:
250 case freeze:
251 case sideswimfreeze:
252 case scrolling:
253 case casting:
254 case sideswimcasting:
255 case landhold1:
256 case landhold2:
257 case waterhold1:
258 case waterhold2:
259 case sidewaterhold1:
260 case sidewaterhold2:
261 case hopping:
262 case inwind:
263 446273 return true;
264 }
265 12413650 return false;
266 12859923 }
267
268 6583157 bool HeroClass::isStanding(bool forJump)
269 {
270
3/4
✓ Branch 0 taken 6578438 times.
✓ Branch 1 taken 4719 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6578438 times.
6583157 if(z || fakez) return false;
271
3/4
✓ Branch 0 taken 252597 times.
✓ Branch 1 taken 6325841 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124659 times.
6703097 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)
272
4/6
✓ Branch 0 taken 124659 times.
✓ Branch 1 taken 127938 times.
✓ Branch 2 taken 124659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124659 times.
✗ Branch 5 not taken.
252597 && !ladderx && !laddery && !getOnSideviewLadder())
273 124659 return false;
274
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6453743 times.
6453779 if(hoverclk) return false;
275
2/2
✓ Branch 0 taken 221368 times.
✓ Branch 1 taken 6232375 times.
6453743 if(nomove_action(action)) return false;
276 6232375 int32_t val = check_pitslide();
277
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 6232361 times.
6232375 if(val == -2) return false;
278
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 6232318 times.
6232361 if(val == -1) return true;
279 43 return forJump;
280 6583157 }
281 17312 bool HeroClass::isLifting()
282 {
283
2/2
✓ Branch 0 taken 1265 times.
✓ Branch 1 taken 16047 times.
17312 if(lift_wpn) return true;
284 16047 return false;
285 17312 }
286 17 void HeroClass::set_liftflags(int liftid)
287 {
288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(unsigned(liftid) >= MAXITEMS)
289 return;
290 17 itemdata const& itm = itemsbuf[liftid];
291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 SETFLAG(liftflags, LIFTFL_DIS_SHIELD, itm.flags & ITEM_FLAG3);
292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 SETFLAG(liftflags, LIFTFL_DIS_ITEMS, itm.flags & ITEM_FLAG4);
293 17 }
294
295 34790 void HeroClass::set_respawn_point(bool setwarp)
296 {
297
2/2
✓ Branch 0 taken 26775 times.
✓ Branch 1 taken 8015 times.
34790 if(setwarp)
298 {
299 8015 warpx = x;
300 8015 warpy = y;
301 8015 raftwarpx = x;
302 8015 raftwarpy = y;
303 8015 }
304
2/2
✓ Branch 0 taken 18702 times.
✓ Branch 1 taken 16088 times.
34790 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
305 {
306
2/2
✓ Branch 0 taken 14457 times.
✓ Branch 1 taken 1631 times.
16088 switch(action)
307 {
308 case none: case walking:
309 14457 break;
310 default:
311 1631 return; //Not a 'safe action'
312 }
313
5/6
✓ Branch 0 taken 13817 times.
✓ Branch 1 taken 640 times.
✓ Branch 2 taken 13817 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 13798 times.
14457 if(z > 0 || fakez > 0 || hoverclk) return; //in air
314
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13798 if(sideview_mode() && !on_sideview_solid(x,y,true)) return; //in air sideview
315
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13783 times.
13798 if(check_pitslide(true) != -1) return; //On a pit
316
317 { //Check water
318 13783 int32_t water = 0;
319 13783 int32_t types[4] = {0};
320 13783 int32_t x1 = x+4, x2 = x+11,
321 13783 y1 = y+9, y2 = y+15;
322
1/2
✓ Branch 0 taken 13783 times.
✗ Branch 1 not taken.
13783 if (get_bit(quest_rules, qr_SMARTER_WATER))
323 {
324
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13783 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13783 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
325 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
326 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
327 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
328 13783 }
329 else
330 {
331 types[0] = COMBOTYPE(x1,y1);
332
333 if(MAPFFCOMBO(x1,y1))
334 types[0] = FFCOMBOTYPE(x1,y1);
335
336 types[1] = COMBOTYPE(x1,y2);
337
338 if(MAPFFCOMBO(x1,y2))
339 types[1] = FFCOMBOTYPE(x1,y2);
340
341 types[2] = COMBOTYPE(x2,y1);
342
343 if(MAPFFCOMBO(x2,y1))
344 types[2] = FFCOMBOTYPE(x2,y1);
345
346 types[3] = COMBOTYPE(x2,y2);
347
348 if(MAPFFCOMBO(x2,y2))
349 types[3] = FFCOMBOTYPE(x2,y2);
350
351 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
352 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
353 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
354
355 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
356 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
357 water = typec;
358 }
359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13783 times.
13783 if(water > 0)
360 {
361 return;
362 }
363 } //End check water
364
365 68915 int poses[4] = {
366 13783 COMBOPOS(x,y+(bigHitbox?0:8)),
367 13783 COMBOPOS(x,y+15),
368 13783 COMBOPOS(x+15,y+(bigHitbox?0:8)),
369 13783 COMBOPOS(x+15,y+15)
370 };
371
2/2
✓ Branch 0 taken 54225 times.
✓ Branch 1 taken 13454 times.
67679 for(auto pos : poses)
372 {
373
2/2
✓ Branch 0 taken 53896 times.
✓ Branch 1 taken 329 times.
54225 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
374 329 return;
375 }
376 13454 }
377 32156 respawn_x = x;
378 32156 respawn_y = y;
379 32156 respawn_scr = currscr;
380 32156 respawn_dmap = currdmap;
381 34790 }
382
383 16 void HeroClass::go_respawn_point()
384 {
385 16 x = respawn_x;
386 16 y = respawn_y;
387 16 handle_portal_prox(&mirror_portal);
388
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 portals.forEach([&](sprite& p)
389 {
390 handle_portal_prox((portal*)&p);
391 return false;
392 });
393 16 warpx=x;
394 16 warpy=y;
395 16 raftwarpx = x;
396 16 raftwarpy = y;
397 16 trySideviewLadder(); //Cling to ladder automatically
398
399
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_bit(quest_rules, qr_OLD_RESPAWN_POINTS))
400 12 return; //No cross-screen return
401
402
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(currdmap != respawn_dmap || currscr != respawn_scr)
403 {
404 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr,
405 -1, -1, 0, 0, warpFlagNOSTEPFORWARD|warpFlagDONTKILLMUSIC, -1);
406 }
407 16 }
408
409 12212 void HeroClass::trySideviewLadder()
410 {
411
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12212 if(canSideviewLadder() && !on_sideview_solid_oldpos(x,y,old_x,old_y))
412 setOnSideviewLadder(true);
413 12212 }
414
415 29303492 bool HeroClass::can_pitfall(bool ignore_hover)
416 {
417
27/30
✓ Branch 0 taken 28719483 times.
✓ Branch 1 taken 584009 times.
✓ Branch 2 taken 28526916 times.
✓ Branch 3 taken 192567 times.
✓ Branch 4 taken 28519098 times.
✓ Branch 5 taken 7818 times.
✓ Branch 6 taken 28519098 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28519014 times.
✓ Branch 9 taken 84 times.
✓ Branch 10 taken 28519014 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 70 times.
✓ Branch 13 taken 28518944 times.
✓ Branch 14 taken 28509667 times.
✓ Branch 15 taken 9347 times.
✓ Branch 16 taken 28508800 times.
✓ Branch 17 taken 867 times.
✓ Branch 18 taken 28507554 times.
✓ Branch 19 taken 1246 times.
✓ Branch 20 taken 28427314 times.
✓ Branch 21 taken 80240 times.
✓ Branch 22 taken 27990905 times.
✓ Branch 23 taken 436409 times.
✓ Branch 24 taken 27990625 times.
✓ Branch 25 taken 280 times.
✓ Branch 26 taken 27990625 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1152 times.
✓ Branch 29 taken 27989473 times.
29303492 return (!(isSideViewGravity()||action==rafting||z>0||fakez>0||fall<0||fakefall<0||(hoverclk && !ignore_hover)||inlikelike||inwallm||pull_hero||toogam||(ladderx||laddery)||getOnSideviewLadder()||drownclk||!(moveflags & FLAG_CAN_PITFALL)));
418 }
419
420 3698739 int32_t HeroClass::DrunkClock()
421 {
422 3698739 return drunkclk;
423 }
424 void HeroClass::setDrunkClock(int32_t newdrunkclk)
425 {
426 drunkclk=newdrunkclk;
427 }
428
429 int32_t HeroClass::StunClock()
430 {
431 return lstunclock;
432 }
433 void HeroClass::setStunClock(int32_t v)
434 {
435 lstunclock=v;
436 }
437
438 98457667 int32_t HeroClass::BunnyClock()
439 {
440 98457667 return lbunnyclock;
441 }
442 void HeroClass::setBunnyClock(int32_t v)
443 {
444 lbunnyclock=v;
445 }
446
447
11/22
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 36 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 36 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 36 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 36 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 36 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 36 times.
✗ Branch 21 not taken.
108 HeroClass::HeroClass() : sprite()
448 72 {
449 36 lift_wpn = nullptr;
450
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 init();
451 36 }
452
453 //2.6
454
455 //Stop the subscreen from falling. -Z
456
457 716 bool HeroClass::stopSubscreenFalling(){
458 716 return preventsubscreenfalling;
459 }
460
461 void HeroClass::stopSubscreenFalling(bool v){
462 preventsubscreenfalling = v;
463 }
464
465
466 //Set the button items by brute force
467
468 void HeroClass::setAButtonItem(int32_t itmslot){
469 game->awpn = itmslot;
470 }
471
472 void HeroClass::setBButtonItem(int32_t itmslot){
473 game->bwpn = itmslot;
474 }
475
476 6406501 void HeroClass::ClearhitHeroUIDs()
477 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
478 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
479 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
480 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
481 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
482 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
483 //clear it on the next frame, but that had the SAME outcome.
484 //Where and how can I clear a value at the end of every frame, so that:
485 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
486 // 2. FFCs can read it before Waitframe. --same.
487 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
488
2/2
✓ Branch 0 taken 108910517 times.
✓ Branch 1 taken 6406501 times.
115317018 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ )
489 {
490 /*
491 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
492 {
493 //Z_scripterrlog("frame is: %d\n", frame);
494 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
495 lastHitBy[q][0] = 0;
496 }
497 */
498 108910517 lastHitBy[q][0] = 0;
499 108910517 }
500 6406501 }
501
502 34306 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
503 {
504 34306 lastHitBy[type][0] = screen_index;
505 34306 }
506
507 2929 int32_t HeroClass::gethitHeroUID(int32_t type)
508 {
509 2929 return lastHitBy[type][0];
510 }
511
512 void HeroClass::set_defence(int32_t type, int32_t v)
513 {
514 defence[type] = v;
515 }
516
517 int32_t HeroClass::get_defence(int32_t type)
518 {
519 return defence[type];
520 }
521
522
523 //Set Hero;s hurt sfx
524 void HeroClass::setHurtSFX(int32_t sfx)
525 {
526 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
527 }
528 6872 int32_t HeroClass::getHurtSFX()
529 {
530 6872 return QMisc.miscsfx[sfxHURTPLAYER];
531 }
532
533 bool HeroClass::getDiagMove()
534 {
535 return diagonalMovement;
536 }
537 void HeroClass::setDiagMove(bool newdiag)
538 {
539 diagonalMovement=newdiag;
540 }
541 9024 bool HeroClass::getBigHitbox()
542 {
543 9024 return bigHitbox;
544 }
545 338 void HeroClass::setBigHitbox(bool newbigHitbox)
546 {
547 338 bigHitbox=newbigHitbox;
548 338 syofs = bigHitbox?0:8;
549 338 sysz_ofs = bigHitbox?0:-8;
550 338 }
551 5424 int32_t HeroClass::getStepRate()
552 {
553 5424 return steprate;
554 }
555 void HeroClass::setStepRate(int32_t newrate)
556 {
557 steprate = newrate;
558 }
559 int32_t HeroClass::getSwimUpRate()
560 {
561 return game->get_sideswim_up();
562 }
563 void HeroClass::setSwimUpRate(int32_t newrate)
564 {
565 game->set_sideswim_up(newrate);
566 }
567 int32_t HeroClass::getSwimSideRate()
568 {
569 return game->get_sideswim_side();
570 }
571 void HeroClass::setSwimSideRate(int32_t newrate)
572 {
573 game->set_sideswim_side(newrate);
574 }
575 int32_t HeroClass::getSwimDownRate()
576 {
577 return game->get_sideswim_down();
578 }
579 void HeroClass::setSwimDownRate(int32_t newrate)
580 {
581 game->set_sideswim_down(newrate);
582 }
583
584
585 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
586 4622374 void HeroClass::herostep()
587 {
588
2/2
✓ Branch 0 taken 4233575 times.
✓ Branch 1 taken 388799 times.
4622374 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
589 //need to run all global/hero/dmap scripts here?
590 4622374 }
591
592 74723 bool is_moving()
593 {
594
6/6
✓ Branch 0 taken 60449 times.
✓ Branch 1 taken 14274 times.
✓ Branch 2 taken 45245 times.
✓ Branch 3 taken 15204 times.
✓ Branch 4 taken 18958 times.
✓ Branch 5 taken 26287 times.
74723 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
595 }
596
597 // called by ALLOFF()
598 13572 void HeroClass::resetflags(bool all)
599 {
600 13572 refilling=REFILL_NONE;
601 13572 inwallm=false;
602 13572 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
603 13572 usecounts.clear();
604
605
4/4
✓ Branch 0 taken 13527 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 13423 times.
13572 if(swordclk>0 || all)
606 {
607 149 swordclk=0;
608 149 verifyAWpn();
609 149 }
610
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 13460 times.
13572 if(itemclk>0 || all)
611 112 itemclk=0;
612
3/4
✓ Branch 0 taken 13572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 13468 times.
13572 if(shieldjinxclk>0 || all)
613 104 shieldjinxclk=0;
614
615
2/2
✓ Branch 0 taken 13468 times.
✓ Branch 1 taken 104 times.
13572 if(all)
616 {
617 104 DivineProtectionShieldClk=0;
618
619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(div_prot_item != -1)
620 {
621 stop_sfx(itemsbuf[div_prot_item].usesound);
622 stop_sfx(itemsbuf[div_prot_item].usesound+1);
623 }
624
625 104 div_prot_item = -1;
626 104 hoverclk=jumping=0;
627 104 hoverflags = 0;
628 104 }
629 13572 damageovertimeclk = 0;
630 13572 newconveyorclk = 0;
631 13572 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
632
2/2
✓ Branch 0 taken 13572 times.
✓ Branch 1 taken 95004 times.
108576 for(auto q = 0; q < 7; ++q)
633 95004 hooked_undercombos[q] = -1;
634 13572 hopclk=0;
635 13572 hopdir=-1;
636 13572 attackclk=0;
637 13572 stomping=false;
638 13572 reset_swordcharge();
639 13572 diveclk=drownclk=drownCombo=0;
640 13572 action=none; FFCore.setHeroAction(none);
641 13572 conveyor_flags=0;
642 13572 magiccastclk=0;
643 13572 magicitem=-1;
644 13572 }
645
646 //Can use this for Hero->Stun. -Z
647 7856 void HeroClass::Freeze()
648 {
649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7856 times.
7856 if (action != inwind)
650 {
651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7856 times.
7856 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
652 7856 else {action=freeze; FFCore.setHeroAction(freeze);}
653 // also cancel Hero's attack
654 7856 attackclk = 0;
655 7856 }
656 7856 }
657 1466 void HeroClass::unfreeze()
658 {
659
3/4
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 860 times.
✓ Branch 2 taken 606 times.
✗ Branch 3 not taken.
1466 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
660
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1466 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1466 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
661 1466 }
662
663 9 void HeroClass::Drown(int32_t state)
664 {
665 // Hero should never drown if the ladder is out
666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(ladderx+laddery)
667 return;
668
669 9 drop_liftwpn();
670
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 switch(state)
671 {
672 case 1:
673 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
674 attackclk=0;
675 attack=wNone;
676 attackid=-1;
677 reset_swordcharge();
678 drownclk=64;
679 z=fakez=fall=fakefall=0;
680 break;
681
682
683 default:
684 {
685
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
686 9 else {action=drowning; FFCore.setHeroAction(drowning);}
687 9 attackclk=0;
688 9 attack=wNone;
689 9 attackid=-1;
690 9 reset_swordcharge();
691 9 drownclk=64;
692 9 z=fakez=fall=fakefall=0;
693 9 break;
694 }
695 }
696
697 9 }
698
699 1138 void HeroClass::finishedmsg()
700 {
701 //these are to cancel out any keys that Hero may
702 //be pressing so he doesn't attack at the end of
703 //a message if he was scrolling through it quickly.
704 1138 rAbtn();
705 1138 rBbtn();
706 1138 unfreeze();
707
708
3/4
✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1122 times.
2260 if(action == landhold1 ||
709
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == landhold2 ||
710
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == waterhold1 ||
711
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == waterhold2 ||
712
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == sidewaterhold1 ||
713 1122 action == sidewaterhold2)
714 {
715 16 holdclk = 1;
716 16 }
717 1138 }
718 35 void HeroClass::setEaten(int32_t i)
719 {
720 35 inlikelike=i;
721 35 }
722 32 int32_t HeroClass::getEaten()
723 {
724 32 return inlikelike;
725 }
726 13713864 zfix HeroClass::getX()
727 {
728 13713864 return x;
729 }
730 13134558 zfix HeroClass::getY()
731 {
732 13134558 return y;
733 }
734 41132040 zfix HeroClass::getZ()
735 {
736 41132040 return z;
737 }
738 27039031 zfix HeroClass::getFakeZ()
739 {
740 27039031 return fakez;
741 }
742 433888 zfix HeroClass::getFall()
743 {
744 433888 return fall;
745 }
746 zfix HeroClass::getFakeFall()
747 {
748 return fakefall;
749 }
750 zfix HeroClass::getXOfs()
751 {
752 return xofs;
753 }
754 zfix HeroClass::getYOfs()
755 {
756 return yofs;
757 }
758 void HeroClass::setXOfs(int32_t newxofs)
759 {
760 xofs=newxofs;
761 }
762 void HeroClass::setYOfs(int32_t newyofs)
763 {
764 yofs=newyofs;
765 }
766 int32_t HeroClass::getHXOfs()
767 {
768 return hxofs;
769 }
770 int32_t HeroClass::getHYOfs()
771 {
772 return hyofs;
773 }
774 int32_t HeroClass::getHXSz()
775 {
776 return hit_width;
777 }
778 int32_t HeroClass::getHYSz()
779 {
780 return hit_height;
781 }
782 35712 zfix HeroClass::getClimbCoverX()
783 {
784 35712 return climb_cover_x;
785 }
786 35712 zfix HeroClass::getClimbCoverY()
787 {
788 35712 return climb_cover_y;
789 }
790 int32_t HeroClass::getLadderX()
791 {
792 return ladderx;
793 }
794 int32_t HeroClass::getLadderY()
795 {
796 return laddery;
797 }
798
799 437394 void HeroClass::setX(int32_t new_x)
800 {
801 437394 zfix dx=new_x-x;
802 437394 justmoved = 2;
803
1/2
✓ Branch 0 taken 437394 times.
✗ Branch 1 not taken.
437394 if(Lwpns.idFirst(wHookshot)>-1)
804 {
805 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
806 hs_startx+=(int32_t)dx;
807 }
808
809
1/2
✓ Branch 0 taken 437394 times.
✗ Branch 1 not taken.
437394 if(Lwpns.idFirst(wHSHandle)>-1)
810 {
811 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
812 }
813
814
1/2
✓ Branch 0 taken 437394 times.
✗ Branch 1 not taken.
437394 if(chainlinks.Count()>0)
815 {
816 for(int32_t j=0; j<chainlinks.Count(); j++)
817 {
818 chainlinks.spr(j)->x+=dx;
819 }
820 }
821
822 437394 x=new_x;
823
824 // A kludge
825
4/4
✓ Branch 0 taken 2543 times.
✓ Branch 1 taken 434851 times.
✓ Branch 2 taken 1591 times.
✓ Branch 3 taken 952 times.
437394 if(!diagonalMovement && dir<=down)
826 952 is_on_conveyor=true;
827 437394 }
828
829 453026 void HeroClass::setY(int32_t new_y)
830 {
831 453026 zfix dy=new_y-y;
832 453026 justmoved = 2;
833
1/2
✓ Branch 0 taken 453026 times.
✗ Branch 1 not taken.
453026 if(Lwpns.idFirst(wHookshot)>-1)
834 {
835 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
836 hs_starty+=(int32_t)dy;
837 }
838
839
1/2
✓ Branch 0 taken 453026 times.
✗ Branch 1 not taken.
453026 if(Lwpns.idFirst(wHSHandle)>-1)
840 {
841 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
842 }
843
844
1/2
✓ Branch 0 taken 453026 times.
✗ Branch 1 not taken.
453026 if(chainlinks.Count()>0)
845 {
846 for(int32_t j=0; j<chainlinks.Count(); j++)
847 {
848 chainlinks.spr(j)->y+=dy;
849 }
850 }
851
852 453026 y=new_y;
853
854 // A kludge
855
4/4
✓ Branch 0 taken 2543 times.
✓ Branch 1 taken 450483 times.
✓ Branch 2 taken 952 times.
✓ Branch 3 taken 1591 times.
453026 if(!diagonalMovement && dir>=left)
856 1591 is_on_conveyor=true;
857 453026 }
858
859 2 void HeroClass::setZ(int32_t new_z)
860 {
861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(isSideViewHero())
862 return;
863
864
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(z==0 && new_z > 0)
865 {
866
1/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 switch(action)
867 {
868 case swimming:
869 {
870 diveclk=0;
871 action=walking; FFCore.setHeroAction(walking);
872 break;
873 }
874
875 case waterhold1:
876 {
877 action=landhold1; FFCore.setHeroAction(landhold1);
878 break;
879 }
880
881 case waterhold2:
882 {
883 action=landhold2; FFCore.setHeroAction(landhold2);
884 break;
885 }
886
887 default:
888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(charging) //!DIMITODO: Let Hero jump while charging sword
889 {
890 reset_swordcharge();
891 attackclk=0;
892 }
893
894 2 break;
895 }
896 2 }
897
898
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 z=(new_z>0 ? new_z : 0);
899 2 }
900
901 void HeroClass::setFakeZ(int32_t new_z)
902 {
903 if(isSideViewHero())
904 return;
905
906 if(fakez==0 && new_z > 0)
907 {
908 switch(action)
909 {
910 case swimming:
911 {
912 diveclk=0;
913 action=walking; FFCore.setHeroAction(walking);
914 break;
915 }
916
917 case waterhold1:
918 {
919 action=landhold1; FFCore.setHeroAction(landhold1);
920 break;
921 }
922
923 case waterhold2:
924 {
925 action=landhold2; FFCore.setHeroAction(landhold2);
926 break;
927 }
928
929 default:
930 if(charging) //!DIMITODO: Let Hero jump while charging sword
931 {
932 reset_swordcharge();
933 attackclk=0;
934 }
935
936 break;
937 }
938 }
939
940 fakez=(new_z>0 ? new_z : 0);
941 }
942
943 1211 void HeroClass::setXfix(zfix new_x)
944 {
945 //Z_scripterrlog("setxdbl: %f\n",new_x);
946 1211 zfix dx=new_x-x;
947 1211 justmoved = 2;
948
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHookshot)>-1)
949 {
950 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
951 hs_startx+=(int32_t)dx;
952 }
953
954
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHSHandle)>-1)
955 {
956 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
957 }
958
959
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(chainlinks.Count()>0)
960 {
961 for(int32_t j=0; j<chainlinks.Count(); j++)
962 {
963 chainlinks.spr(j)->x+=dx;
964 }
965 }
966
967 1211 x=new_x;
968
969 // A kludge
970
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1211 if(!diagonalMovement && dir<=down)
971 is_on_conveyor=true;
972 1211 }
973
974 1081 void HeroClass::setYfix(zfix new_y)
975 {
976 1081 zfix dy=new_y-y;
977 1081 justmoved = 2;
978
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHookshot)>-1)
979 {
980 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
981 hs_starty+=(int32_t)dy;
982 }
983
984
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHSHandle)>-1)
985 {
986 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
987 }
988
989
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(chainlinks.Count()>0)
990 {
991 for(int32_t j=0; j<chainlinks.Count(); j++)
992 {
993 chainlinks.spr(j)->y+=dy;
994 }
995 }
996
997 1081 y=new_y;
998
999 // A kludge
1000
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1081 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1081 if(!diagonalMovement && dir>=left)
1001 is_on_conveyor=true;
1002 1081 }
1003
1004 2767 void HeroClass::setZfix(zfix new_z)
1005 {
1006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767 times.
2767 if(isSideViewHero())
1007 return;
1008
1009
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2754 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 7 times.
2767 if(z==0 && new_z > 0)
1010 {
1011
1/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 switch(action)
1012 {
1013 case swimming:
1014 {
1015 diveclk=0;
1016 action=walking; FFCore.setHeroAction(walking);
1017 break;
1018 }
1019
1020 case waterhold1:
1021 {
1022 action=landhold1; FFCore.setHeroAction(landhold1);
1023 break;
1024 }
1025
1026 case waterhold2:
1027 {
1028 action=landhold2; FFCore.setHeroAction(landhold2);
1029 break;
1030 }
1031
1032 default:
1033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(charging) //!DIMITODO: Let Hero jump while charging sword
1034 {
1035 reset_swordcharge();
1036 attackclk=0;
1037 }
1038
1039 7 break;
1040 }
1041 7 }
1042
1043
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 6 times.
2767 z=(new_z>0 ? new_z : zfix(0));
1044 2767 }
1045
1046 void HeroClass::setFakeZfix(zfix new_z)
1047 {
1048 if(isSideViewHero())
1049 return;
1050
1051 if(fakez==0 && new_z > 0)
1052 {
1053 switch(action)
1054 {
1055 case swimming:
1056 {
1057 diveclk=0;
1058 action=walking; FFCore.setHeroAction(walking);
1059 break;
1060 }
1061
1062 case waterhold1:
1063 {
1064 action=landhold1; FFCore.setHeroAction(landhold1);
1065 break;
1066 }
1067
1068 case waterhold2:
1069 {
1070 action=landhold2; FFCore.setHeroAction(landhold2);
1071 break;
1072 }
1073
1074 default:
1075 if(charging) //!DIMITODO: Let Hero jump while charging sword
1076 {
1077 reset_swordcharge();
1078 attackclk=0;
1079 }
1080
1081 break;
1082 }
1083 }
1084
1085 fakez=(new_z>0 ? new_z : zfix(0));
1086 }
1087
1088 64402 void HeroClass::setFall(zfix new_fall)
1089 {
1090 64402 fall=new_fall;
1091 64402 justmoved = 2;
1092 64402 jumping=-1;
1093 64402 }
1094 void HeroClass::setFakeFall(zfix new_fall)
1095 {
1096 fakefall=new_fall;
1097 jumping=-1;
1098 }
1099 void HeroClass::setClimbCoverX(int32_t new_x)
1100 {
1101 climb_cover_x=new_x;
1102 }
1103 void HeroClass::setClimbCoverY(int32_t new_y)
1104 {
1105 climb_cover_y=new_y;
1106 }
1107 43693 int32_t HeroClass::getLStep()
1108 {
1109 43693 return lstep;
1110 }
1111 3678 int32_t HeroClass::getCharging()
1112 {
1113 3678 return charging;
1114 }
1115 59935 bool HeroClass::isCharged()
1116 {
1117 59935 return spins>0;
1118 }
1119 int32_t HeroClass::getAttackClk()
1120 {
1121 return attackclk;
1122 }
1123 void HeroClass::setAttackClk(int32_t new_clk)
1124 {
1125 attackclk=new_clk;
1126 }
1127 void HeroClass::setCharging(int32_t new_charging)
1128 {
1129 charging=new_charging;
1130 }
1131 2827817279 int32_t HeroClass::getSwordClk()
1132 {
1133 2827817279 return swordclk;
1134 }
1135 2798681784 int32_t HeroClass::getItemClk()
1136 {
1137 2798681784 return itemclk;
1138 }
1139 6 void HeroClass::setSwordClk(int32_t newclk)
1140 {
1141 6 swordclk=newclk;
1142 6 verifyAWpn();
1143 6 }
1144 108 void HeroClass::setItemClk(int32_t newclk)
1145 {
1146 108 itemclk=newclk;
1147 108 }
1148 // TODO remove, no longer needed.
1149 697109 zfix HeroClass::getModifiedX()
1150 {
1151 697109 zfix tempx=x;
1152 697109 return tempx;
1153 }
1154
1155 697109 zfix HeroClass::getModifiedY()
1156 {
1157 697109 zfix tempy=y;
1158 697109 return tempy;
1159 }
1160
1161 18271 int32_t HeroClass::getDir()
1162 {
1163 18271 return dir;
1164 }
1165 31042 void HeroClass::setDir(int32_t newdir)
1166 {
1167 31042 dir=newdir;
1168 31042 reset_hookshot();
1169 31042 }
1170 int32_t HeroClass::getHitDir()
1171 {
1172 return hitdir;
1173 }
1174 void HeroClass::setHitDir(int32_t newdir)
1175 {
1176 hitdir = newdir;
1177 }
1178 int32_t HeroClass::getClk()
1179 {
1180 return clk;
1181 }
1182 int32_t HeroClass::getPushing()
1183 {
1184 return pushing;
1185 }
1186 8597 void HeroClass::Catch()
1187 {
1188
5/6
✓ Branch 0 taken 8597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6528 times.
✓ Branch 3 taken 2069 times.
✓ Branch 4 taken 3662 times.
✓ Branch 5 taken 2866 times.
8597 if(!inwallm && (action==none || action==walking))
1189 {
1190 5731 SetAttack();
1191 5731 attackclk=0;
1192 5731 attack=wCatching;
1193 5731 }
1194 8597 }
1195
1196 5152649 bool HeroClass::getClock()
1197 {
1198 5152649 return superman;
1199 }
1200 768 void HeroClass::setClock(bool state)
1201 {
1202 768 superman=state;
1203 768 }
1204 41881408 int32_t HeroClass::getAction() // Used by ZScript
1205 {
1206
2/2
✓ Branch 0 taken 7632 times.
✓ Branch 1 taken 41873776 times.
41881408 if(spins > 0)
1207 7632 return isspinning;
1208
2/2
✓ Branch 0 taken 17289 times.
✓ Branch 1 taken 41856487 times.
41873776 else if(charging > 0)
1209 17289 return ischarging;
1210
2/2
✓ Branch 0 taken 41819563 times.
✓ Branch 1 taken 36924 times.
41856487 else if(diveclk > 0)
1211 36924 return isdiving;
1212 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1213
1214 41819563 return action;
1215 41881408 }
1216
1217 27415453 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1218 {
1219
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 27414605 times.
27415453 if(spins > 0)
1220 848 return isspinning;
1221
2/2
✓ Branch 0 taken 1921 times.
✓ Branch 1 taken 27412684 times.
27414605 else if(charging > 0)
1222 1921 return ischarging;
1223
2/2
✓ Branch 0 taken 27318796 times.
✓ Branch 1 taken 93888 times.
27412684 else if(diveclk > 0)
1224 93888 return isdiving;
1225 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1226
1227 27318796 return -1;
1228 27415453 }
1229
1230 392 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1231 {
1232
4/8
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 392 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 392 times.
784 if(new_action==dying || new_action==won || new_action==scrolling ||
1233
3/6
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 392 times.
✗ Branch 5 not taken.
392 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1234 392 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1235 return; // Can't use these actions.
1236
1237
3/6
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 193 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
392 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1238 return;
1239
1240
1/2
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
392 if(new_action==rafting)
1241 {
1242 if(get_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING)) return;
1243 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1244 return;
1245 }
1246
1247
1248
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(magicitem>-1 && itemsbuf[magicitem].family==itype_divineescape)
1249 {
1250 // Using Divine Escape
1251 if(magiccastclk<96)
1252 {
1253 // Not cast yet; cancel it
1254 magicitem=-1;
1255 magiccastclk=0;
1256 }
1257 else
1258 // Already activated; don't do anything
1259 return;
1260 }
1261
1262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
392 if(action==inwind) // Remove from whirlwind
1263 {
1264 xofs=0;
1265 whirlwind=0;
1266 lstep=0;
1267 if ( dontdraw < 2 ) { dontdraw=0; }
1268 }
1269
2/4
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392 times.
392 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1270 {
1271 sprite* wind=0;
1272 bool foundWind=false;
1273 for(int32_t i=0; i<Ewpns.Count(); i++)
1274 {
1275 wind=Ewpns.spr(i);
1276 if(wind->id==ewWind && wind->misc==999)
1277 {
1278 foundWind=true;
1279 break;
1280 }
1281 }
1282
1283 if(foundWind)
1284 {
1285 xofs=0;
1286 if ( dontdraw < 2 ) { dontdraw=false; }
1287 wind->misc=-1;
1288 x=wind->x;
1289 y=wind->y;
1290 }
1291 }
1292
1293 //Unless compat rule is on, reset hopping clocks when writing action!
1294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(action == hopping && !get_bit(quest_rules,qr_NO_OVERWRITING_HOPPING))
1295 {
1296 hopclk = 0;
1297 hopdir = -1;
1298 }
1299
1300
3/4
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267 times.
392 if(new_action != attacking && new_action != sideswimattacking)
1301 {
1302 267 attackclk=0;
1303
1304
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(attack==wHookshot)
1305 reset_hookshot();
1306 267 }
1307
2/4
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392 times.
392 if(new_action != isspinning && new_action != sideswimisspinning)
1308 {
1309 392 charging = 0;
1310 392 spins = 0;
1311 392 }
1312
1313
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(action == falling && new_action != falling)
1314 {
1315 fallclk = 0; //Stop falling;
1316 }
1317
1318
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if (action == rafting && new_action != rafting)
1319 {
1320 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1321 raftwarpy = y;
1322 }
1323
1324
2/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 267 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
392 switch(new_action)
1325 {
1326 case isspinning:
1327 case sideswimisspinning:
1328 if(attack==wSword)
1329 {
1330 attackclk = SWORDCHARGEFRAME+1;
1331 charging = 0;
1332
1333 if(spins==0)
1334 spins = 5;
1335 }
1336 return;
1337
1338 case isdiving:
1339 if(action==swimming && diveclk==0)
1340 {
1341 int32_t flippers_id = current_item_id(itype_flippers);
1342 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1343 }
1344 return;
1345
1346 case drowning:
1347 case sidedrowning:
1348 //I would add a sanity check to see if Hero is in water, but I *KNOW* that quests have used this
1349 // INTENTIONALLY while Hero is on Land, as a blink-out effect. :( -Z
1350 if(!drownclk)
1351 Drown();
1352
1353 break;
1354
1355 case lavadrowning:
1356 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1357 if(!drownclk)
1358 Drown(1);
1359
1360 break;
1361
1362 case falling:
1363 if(!fallclk)
1364 {
1365 //If there is a pit under Hero, use it's combo.
1366 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1367 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1368 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1369 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1370 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1371 //Else, use a null value; triggers default pit values
1372 else fallCombo = 0;
1373 fallclk = PITFALL_FALL_FRAMES;
1374 }
1375 break;
1376
1377 case gothit:
1378 case swimhit:
1379 case sideswimhit:
1380 if(!hclk)
1381 hclk=48;
1382
1383 break;
1384
1385 case landhold1:
1386 case landhold2:
1387 case waterhold1:
1388 case waterhold2:
1389 case sidewaterhold1:
1390 case sidewaterhold2:
1391 if(!holdclk)
1392 holdclk=130;
1393
1394 attack=none;
1395 break;
1396
1397 case attacking:
1398 case sideswimattacking:
1399 125 attack=none;
1400 125 break;
1401
1402 default:
1403 267 break;
1404 }
1405
1406 392 action=new_action; FFCore.setHeroAction(new_action);
1407 392 }
1408
1409 void HeroClass::setHeldItem(int32_t newitem)
1410 {
1411 holditem=newitem;
1412 }
1413 17 int32_t HeroClass::getHeldItem()
1414 {
1415 17 return holditem;
1416 }
1417 6162475 bool HeroClass::isDiving()
1418 {
1419 6162475 int32_t flippers_id = current_item_id(itype_flippers);
1420
2/2
✓ Branch 0 taken 4500472 times.
✓ Branch 1 taken 1662003 times.
6162475 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1421 }
1422 13616613 bool HeroClass::isSwimming()
1423 {
1424
4/6
✓ Branch 0 taken 13474941 times.
✓ Branch 1 taken 141672 times.
✓ Branch 2 taken 13474941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13474941 times.
✗ Branch 5 not taken.
27091554 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1425
4/4
✓ Branch 0 taken 13473511 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 390 times.
✓ Branch 3 taken 13473121 times.
13474941 (action==waterhold1)||(action==waterhold2)||
1426 13473121 (hopclk==0xFF));
1427 }
1428
1429 774 void HeroClass::setDontDraw(byte new_dontdraw)
1430 {
1431 774 dontdraw=new_dontdraw;
1432 774 }
1433
1434 569605 byte HeroClass::getDontDraw()
1435 {
1436 569605 return dontdraw;
1437 }
1438
1439 void HeroClass::setHClk(int32_t newhclk)
1440 {
1441 hclk=newhclk;
1442 }
1443
1444 87306 int32_t HeroClass::getHClk()
1445 {
1446 87306 return hclk;
1447 }
1448
1449 4156699 int32_t HeroClass::getSpecialCave()
1450 {
1451 4156699 return specialcave; // used only by maps.cpp
1452 }
1453
1454 338 void HeroClass::init()
1455 {
1456 338 usecounts.clear();
1457 338 scale = 0;
1458 338 rotation = 0;
1459 338 do_animation = 1;
1460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 338 times.
338 if(lift_wpn)
1461 {
1462 delete lift_wpn;
1463 lift_wpn = nullptr;
1464 }
1465 338 liftclk = 0;
1466 338 tliftclk = 0;
1467 338 liftheight = 0;
1468 338 liftflags = 0;
1469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 338 times.
338 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1470 338 hookshot_used=false;
1471 338 justmoved = 0;
1472 338 hookshot_frozen=false;
1473 338 onpassivedmg=false;
1474 338 dir = up;
1475 338 damageovertimeclk = 0;
1476 338 newconveyorclk = 0;
1477 338 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1478
2/2
✓ Branch 0 taken 2366 times.
✓ Branch 1 taken 338 times.
2704 for(auto q = 0; q < 7; ++q)
1479 2366 hooked_undercombos[q] = -1;
1480 338 shiftdir = -1;
1481 338 sideswimdir = right;
1482 338 holddir = -1;
1483 338 landswim = 0;
1484 338 sdir = up;
1485 338 ilswim=true;
1486 338 walkable=false;
1487 338 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1488 338 warp_sound = 0;
1489 338 subscr_speed = zinit.subscrSpeed;
1490 338 steprate = zinit.heroStep;
1491 338 is_warping = false;
1492 338 coyotetime = 0;
1493
1494 338 hammer_swim_up_offset = hammeroffsets[0];
1495 338 hammer_swim_down_offset = hammeroffsets[1];
1496 338 hammer_swim_left_offset = hammeroffsets[2];
1497 338 hammer_swim_right_offset = hammeroffsets[3];
1498
1499 338 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1500
1501
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 239 times.
338 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
1502 {
1503 99 x=tmpscr->warpreturnx[0];
1504 99 y=tmpscr->warpreturny[0];
1505 99 }
1506 else
1507 {
1508 239 x=tmpscr->warparrivalx;
1509 239 y=tmpscr->warparrivaly;
1510 }
1511
1512 338 z=fakez=fall=fakefall=0;
1513 338 hzsz = 12; // So that flying peahats can still hit him.
1514
1515
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 270 times.
338 if(x==0) dir=right;
1516
1517
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 337 times.
338 if(x==240) dir=left;
1518
1519
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 263 times.
338 if(y==0) dir=down;
1520
1521
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 244 times.
338 if(y==160) dir=up;
1522
1523 338 lstep=0;
1524 338 skipstep=0;
1525 338 autostep=false;
1526 338 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1527 338 attack=wNone;
1528 338 attackid=-1;
1529 338 action=none; FFCore.setHeroAction(none); tempaction=none;
1530 338 xofs=0;
1531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 338 times.
338 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1532 338 cs=6;
1533 338 pushing=fairyclk=0;
1534 338 id=0;
1535 338 inlikelike=0;
1536 338 superman=inwallm=false;
1537 338 scriptcoldet=1;
1538 338 blowcnt=whirlwind=specialcave=0;
1539 338 hopclk=diveclk=fallclk=0;
1540 338 fallCombo = 0;
1541 338 pit_pulldir = -1;
1542 338 hopdir=-1;
1543 338 conveyor_flags=0;
1544 338 drunkclk=0;
1545 338 lstunclock = 0;
1546 338 is_conveyor_stunned=0;
1547 338 convey_forcex=convey_forcey=0;
1548 338 drawstyle=3;
1549 338 ffwarp = false;
1550 338 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1551 338 stepnext=stepsecret=-1;
1552 338 ffpit = false;
1553 338 respawn_x=x;
1554 338 respawn_y=y;
1555 338 respawn_dmap=currdmap;
1556 338 respawn_scr=currscr;
1557 338 falling_oldy = y;
1558 338 magiccastclk=0;
1559 338 magicitem = div_prot_item = -1;
1560 338 last_lens_id = 0; //Should be -1 (-Z)
1561 338 last_savepoint_id = 0;
1562 338 misc_internal_hero_flags = 0;
1563 338 last_cane_of_byrna_item_id = -1;
1564 338 on_sideview_ladder = false;
1565 338 switchblock_z = 0;
1566 338 switchblock_offset = false;
1567 338 extra_jump_count = 0;
1568 338 hoverflags = 0;
1569 338 lbunnyclock = 0;
1570
1571
2/2
✓ Branch 0 taken 10816 times.
✓ Branch 1 taken 338 times.
11154 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1572
1573 338 setBigHitbox(get_bit(quest_rules, qr_LTTPCOLLISION));
1574 338 diagonalMovement=(get_bit(quest_rules,qr_LTTPWALK));
1575
1576 338 shield_active = false;
1577 338 shield_forcedir = -1;
1578 338 active_shield_id = -1;
1579
1580 //2.6
1581 338 preventsubscreenfalling = false; //-Z
1582 338 walkspeed = 0; //not used, yet. -Z
1583
2/2
✓ Branch 0 taken 5746 times.
✓ Branch 1 taken 338 times.
6084 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1584
2/2
✓ Branch 0 taken 5746 times.
✓ Branch 1 taken 338 times.
6084 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1585
2/2
✓ Branch 0 taken 49348 times.
✓ Branch 1 taken 338 times.
49686 for ( int32_t q = 0; q < wMax; q++ )
1586 {
1587 49348 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1588 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1589 49348 }
1590 //Run script!
1591
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 305 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 19 times.
338 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1592 {
1593 14 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_INIT, SCRIPT_PLAYER_INIT);
1594 14 FFCore.deallocateAllArrays(ScriptType::Player, SCRIPT_PLAYER_INIT);
1595 14 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1596 14 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1597 //are properly set by the engine.
1598 14 }
1599 338 FFCore.nostepforward = 0;
1600
1601
4/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 236 times.
338 if (!replay_is_active() || replay_get_version() >= 12)
1602 102 z3step = 2;
1603 338 }
1604
1605 7271531 void HeroClass::draw_under(BITMAP* dest)
1606 {
1607 7271531 int32_t c_raft=current_item_id(itype_raft);
1608 7271531 int32_t c_ladder=current_item_id(itype_ladder);
1609
1610
3/4
✓ Branch 0 taken 80476 times.
✓ Branch 1 taken 7191055 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80476 times.
7271531 if(action==rafting && c_raft >-1)
1611 {
1612
4/4
✓ Branch 0 taken 59051 times.
✓ Branch 1 taken 21425 times.
✓ Branch 2 taken 41054 times.
✓ Branch 3 taken 39422 times.
80476 if(((dir==left) || (dir==right)) && (get_bit(quest_rules,qr_RLFIX)))
1613 {
1614 78844 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1615 39422 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1616 39422 }
1617 else
1618 {
1619 82108 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1620 41054 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1621 }
1622 80476 }
1623
1624
3/4
✓ Branch 0 taken 97855 times.
✓ Branch 1 taken 7173676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97855 times.
7271531 if(ladderx+laddery && c_ladder >-1)
1625 {
1626
4/4
✓ Branch 0 taken 44432 times.
✓ Branch 1 taken 53423 times.
✓ Branch 2 taken 26065 times.
✓ Branch 3 taken 18367 times.
97855 if((ladderdir>=left) && (get_bit(quest_rules,qr_RLFIX)))
1627 {
1628 52130 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1629 26065 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1630 26065 }
1631 else
1632 {
1633 143580 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1634 71790 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1635 }
1636 97855 }
1637 7271531 }
1638
1639 3997 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1640 {
1641 3997 int32_t tempy=yofs;
1642 3997 yofs+=8;
1643 3997 shadowtile = wpnsbuf[spr_shadow].tile;
1644 3997 sprite::drawshadow(dest,translucent);
1645 3997 yofs=tempy;
1646 3997 }
1647
1648 // The Stone of Agony reacts to these flags.
1649 487612 bool HeroClass::agonyflag(int32_t flag)
1650 {
1651
2/2
✓ Branch 0 taken 487580 times.
✓ Branch 1 taken 32 times.
487612 switch(flag)
1652 {
1653 case mfWHISTLE:
1654 case mfANYFIRE:
1655 case mfARROW:
1656 case mfBOMB:
1657 case mfSBOMB:
1658 case mfBRANG:
1659 case mfMBRANG:
1660 case mfFBRANG:
1661 case mfSARROW:
1662 case mfGARROW:
1663 case mfSTRONGFIRE:
1664 case mfMAGICFIRE:
1665 case mfDIVINEFIRE:
1666 case mfWANDMAGIC:
1667 case mfREFMAGIC:
1668 case mfREFFIREBALL:
1669 case mfSWORD:
1670 case mfWSWORD:
1671 case mfMSWORD:
1672 case mfXSWORD:
1673 case mfSWORDBEAM:
1674 case mfWSWORDBEAM:
1675 case mfMSWORDBEAM:
1676 case mfXSWORDBEAM:
1677 case mfHOOKSHOT:
1678 case mfWAND:
1679 case mfHAMMER:
1680 case mfSTRIKE:
1681 32 return true;
1682 }
1683
1684 487580 return false;
1685 487612 }
1686
1687
1688 // Find the attack power of the current melee weapon.
1689 // The Whimsical Ring is applied on a target-by-target basis.
1690 469151 int32_t HeroClass::weaponattackpower(int32_t itid)
1691 {
1692
1/2
✓ Branch 0 taken 469151 times.
✗ Branch 1 not taken.
469151 if(itid < 0)
1693 {
1694 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1695 : attack==wWand ? itype_wand
1696 : attack==wHammer ? itype_hammer
1697 : itype_sword);
1698 }
1699
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 469131 times.
469151 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1700
1701 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1702
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 468577 times.
469151 if(spins > 0)
1703 {
1704 574 int scr = currentscroll;
1705
1/2
✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
574 if(scr < 0)
1706 {
1707 scr = current_item_id(attack==wHammer ? (spins>1?itype_quakescroll2:itype_quakescroll)
1708 : (spins>5 || current_item_id(itype_spinscroll) < 0)
1709 ? itype_spinscroll2 : itype_spinscroll);
1710 }
1711 574 power *= itemsbuf[scr].power;
1712 574 }
1713 468577 else currentscroll = -1;
1714 469151 return power;
1715 }
1716
1717 #define NET_CLK_TOTAL 24
1718 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1719 // Must only be called once per frame!
1720 void HeroClass::positionNet(weapon *w, int32_t itemid)
1721 {
1722 itemid = vbound(itemid, 0, MAXITEMS-1);
1723 int32_t t = w->o_tile,
1724 wx = 1, wy = 1;
1725
1726 //Invert positioning clock if right-handed animation
1727 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1728 if(clock >= NET_CLK_TOTAL)
1729 w->dead = 0;
1730 int32_t tiledir = dir;
1731 switch(dir)
1732 {
1733 case up:
1734 {
1735 if(clock < NET_DIR_INC) tiledir = l_up;
1736 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1737 break;
1738 }
1739 case down:
1740 {
1741 if(clock < NET_DIR_INC) tiledir = r_down;
1742 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1743 break;
1744 }
1745 case left:
1746 {
1747 if(clock < NET_DIR_INC) tiledir = l_down;
1748 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1749 break;
1750 }
1751 case right:
1752 {
1753 if(clock < NET_DIR_INC) tiledir = r_up;
1754 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1755 break;
1756 }
1757 }
1758 int32_t offs = 0;
1759 if(tiledir > right)
1760 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1761 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1762 //One of 8 positions
1763 switch(tiledir)
1764 {
1765 case up:
1766 {
1767 wx = 6*offs;
1768 wy = -14;
1769 break;
1770 }
1771 case r_up:
1772 {
1773 wx = (offs ? 10 : 14);
1774 wy = (offs ? -12 : -10);
1775 break;
1776 }
1777 case right:
1778 {
1779 wx = 14;
1780 wy = 6*offs;
1781 break;
1782 }
1783 case r_down:
1784 {
1785 wx = (offs ? 14 : 10);
1786 wy = (offs ? 10 : 12);
1787 break;
1788 }
1789 case down:
1790 {
1791 wx = -6*offs;
1792 wy = 14;
1793 break;
1794 }
1795 case l_down:
1796 {
1797 wx = (offs ? -10 : -14);
1798 wy = (offs ? 12 : 10);
1799 break;
1800 }
1801 case left:
1802 {
1803 wx = -14;
1804 wy = -6*offs;
1805 break;
1806 }
1807 case l_up:
1808 {
1809 wx = (offs ? -14 : -10);
1810 wy = (offs ? -10 : -12);
1811 break;
1812 }
1813 }
1814
1815 w->x = x+wx;
1816 w->y = y+wy-(54-(yofs))-fakez;
1817 w->z = (z+zofs);
1818 w->fakez = fakez;
1819 w->tile = t+tiledir;
1820 w->power = 0;
1821 w->dir = dir;
1822 w->doAutoRotate(true);
1823 }
1824 412705 void HeroClass::positionSword(weapon *w, int32_t itemid)
1825 {
1826 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
1827 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
1828 412705 itemid=vbound(itemid, 0, MAXITEMS-1);
1829 // Place a sword weapon at the right spot.
1830 412705 int32_t wy=1;
1831 412705 int32_t wx=1;
1832 412705 int32_t f=0,t,cs2;
1833
1834 412705 t = w->o_tile;
1835 412705 cs2 = w->o_cset;
1836 412705 slashxofs=0;
1837 412705 slashyofs=0;
1838
1839
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 94218 times.
✓ Branch 2 taken 89969 times.
✓ Branch 3 taken 113170 times.
✓ Branch 4 taken 115348 times.
412705 switch(dir)
1840 {
1841 case up:
1842 94218 wx=-1;
1843 94218 wy=-12;
1844
1845
7/8
✓ Branch 0 taken 6697 times.
✓ Branch 1 taken 87521 times.
✓ Branch 2 taken 5644 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 5234 times.
✓ Branch 5 taken 410 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5234 times.
94218 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1846 {
1847
2/2
✓ Branch 0 taken 3422 times.
✓ Branch 1 taken 1812 times.
5234 if(attackclk>10) //extended stab
1848 {
1849 1812 slashyofs-=3;
1850 1812 wy-=2;
1851 1812 }
1852
1853
2/2
✓ Branch 0 taken 4782 times.
✓ Branch 1 taken 452 times.
5234 if(attackclk>=14) //retracting stab
1854 {
1855 452 slashyofs+=3;
1856 452 wy+=2;
1857 452 }
1858 5234 }
1859 else
1860 {
1861
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 88698 times.
88984 if(attackclk==SWORDCHARGEFRAME)
1862 {
1863 286 wy+=4;
1864 286 }
1865
2/2
✓ Branch 0 taken 8612 times.
✓ Branch 1 taken 80086 times.
88698 else if(attackclk==13)
1866 {
1867 8612 wy+=4;
1868 8612 }
1869
2/2
✓ Branch 0 taken 71572 times.
✓ Branch 1 taken 8514 times.
80086 else if(attackclk==14)
1870 {
1871 8514 wy+=8;
1872 8514 }
1873 }
1874
1875 94218 break;
1876
1877 case down:
1878 89969 f=get_bit(quest_rules,qr_SWORDWANDFLIPFIX)?3:2;
1879 89969 wy=11;
1880
1881
7/8
✓ Branch 0 taken 9274 times.
✓ Branch 1 taken 80695 times.
✓ Branch 2 taken 8517 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 8157 times.
✓ Branch 5 taken 360 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8157 times.
89969 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1882 {
1883
2/2
✓ Branch 0 taken 5295 times.
✓ Branch 1 taken 2862 times.
8157 if(attackclk>10) //extended stab
1884 {
1885 2862 slashyofs+=3;
1886 2862 wy+=2;
1887 2862 }
1888
1889
2/2
✓ Branch 0 taken 7453 times.
✓ Branch 1 taken 704 times.
8157 if(attackclk>=14) //retracting stab
1890 {
1891 704 slashyofs-=3;
1892 704 wy-=2;
1893 704 }
1894 8157 }
1895 else
1896 {
1897
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 81212 times.
81812 if(attackclk==SWORDCHARGEFRAME)
1898 {
1899 600 wy-=2;
1900 600 }
1901
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 73220 times.
81212 else if(attackclk==13)
1902 {
1903 7992 wy-=4;
1904 7992 }
1905
2/2
✓ Branch 0 taken 65256 times.
✓ Branch 1 taken 7964 times.
73220 else if(attackclk==14)
1906 {
1907 7964 wy-=8;
1908 7964 }
1909 }
1910
1911 89969 break;
1912
1913 case left:
1914 113170 f=1;
1915 113170 wx=-11;
1916 113170 ++t;
1917
1918
7/8
✓ Branch 0 taken 12777 times.
✓ Branch 1 taken 100393 times.
✓ Branch 2 taken 10459 times.
✓ Branch 3 taken 2318 times.
✓ Branch 4 taken 9607 times.
✓ Branch 5 taken 852 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9607 times.
113170 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1919 {
1920
2/2
✓ Branch 0 taken 6158 times.
✓ Branch 1 taken 3449 times.
9607 if(attackclk>10) //extended stab
1921 {
1922 3449 slashxofs-=4;
1923 3449 wx-=7;
1924 3449 }
1925
1926
2/2
✓ Branch 0 taken 8750 times.
✓ Branch 1 taken 857 times.
9607 if(attackclk>=14) //retracting stab
1927 {
1928 857 slashxofs+=3;
1929 857 wx+=7;
1930 857 }
1931 9607 }
1932 else
1933 {
1934
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 103360 times.
103563 if(attackclk==SWORDCHARGEFRAME)
1935 {
1936 203 wx+=2;
1937 203 }
1938
2/2
✓ Branch 0 taken 10192 times.
✓ Branch 1 taken 93168 times.
103360 else if(attackclk==13)
1939 {
1940 10192 wx+=4;
1941 10192 }
1942
2/2
✓ Branch 0 taken 83012 times.
✓ Branch 1 taken 10156 times.
93168 else if(attackclk==14)
1943 {
1944 10156 wx+=8;
1945 10156 }
1946 }
1947
1948 113170 break;
1949
1950 case right:
1951 115348 wx=11;
1952 115348 ++t;
1953
1954
7/8
✓ Branch 0 taken 12981 times.
✓ Branch 1 taken 102367 times.
✓ Branch 2 taken 11104 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 9270 times.
✓ Branch 5 taken 1834 times.
✓ Branch 6 taken 9270 times.
✗ Branch 7 not taken.
115348 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1955 {
1956
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 3326 times.
9270 if(attackclk>10) //extended stab
1957 {
1958 3326 slashxofs+=4;
1959 3326 wx+=7;
1960 3326 }
1961
1962
2/2
✓ Branch 0 taken 8440 times.
✓ Branch 1 taken 830 times.
9270 if(attackclk>=14) //retracting stab
1963 {
1964 830 slashxofs-=3;
1965 830 wx-=7;
1966 830 }
1967 9270 }
1968 else
1969 {
1970
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 105483 times.
106078 if(attackclk==SWORDCHARGEFRAME)
1971 {
1972 595 wx-=2;
1973 595 }
1974
2/2
✓ Branch 0 taken 10375 times.
✓ Branch 1 taken 95108 times.
105483 else if(attackclk==13)
1975 {
1976 10375 wx-=4;
1977 10375 }
1978
2/2
✓ Branch 0 taken 84760 times.
✓ Branch 1 taken 10348 times.
95108 else if(attackclk==14)
1979 {
1980 10348 wx-=8;
1981 10348 }
1982 }
1983
1984 115348 break;
1985 }
1986
1987
6/6
✓ Branch 0 taken 41729 times.
✓ Branch 1 taken 370976 times.
✓ Branch 2 taken 32288 times.
✓ Branch 3 taken 9441 times.
✓ Branch 4 taken 11457 times.
✓ Branch 5 taken 20831 times.
412705 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
1988 {
1989 20831 int32_t wpn2=itemsbuf[itemid].wpn2;
1990 20831 wpn2=vbound(wpn2, 0, MAXWPNS);
1991
1992 //slashing tiles
1993
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3422 times.
✓ Branch 2 taken 5301 times.
✓ Branch 3 taken 6158 times.
✓ Branch 4 taken 5950 times.
20831 switch(dir)
1994 {
1995 case up:
1996 3422 wx=15;
1997 3422 wy=-3;
1998 3422 ++t;
1999 3422 f=0; //starts pointing right
2000
2001
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 1886 times.
3422 if(attackclk>=7)
2002 {
2003 1886 wy-=9;
2004 1886 wx-=3;
2005 1886 t = wpnsbuf[wpn2].tile;
2006 1886 cs2 = wpnsbuf[wpn2].csets&15;
2007 1886 f=0;
2008 1886 }
2009
2010 3422 break;
2011
2012 case down:
2013 5301 wx=-13;
2014 5301 wy=-1;
2015 5301 ++t;
2016 5301 f=1; //starts pointing left
2017
2018
2/2
✓ Branch 0 taken 2307 times.
✓ Branch 1 taken 2994 times.
5301 if(attackclk>=7)
2019 {
2020 2994 wy+=15;
2021 2994 wx+=2;
2022 2994 t = wpnsbuf[wpn2].tile;
2023 2994 cs2 = wpnsbuf[wpn2].csets&15;
2024 2994 ++t;
2025 2994 f=0;
2026 2994 }
2027
2028 5301 break;
2029
2030 case left:
2031 6158 wx=3;
2032 6158 wy=-15;
2033 6158 --t;
2034 6158 f=0; //starts pointing up
2035
2036
2/2
✓ Branch 0 taken 2667 times.
✓ Branch 1 taken 3491 times.
6158 if(attackclk>=7)
2037 {
2038 3491 wx-=15;
2039 3491 wy+=3;
2040 3491 slashxofs-=1;
2041 3491 t = wpnsbuf[wpn2].tile;
2042 3491 cs2 = wpnsbuf[wpn2].csets&15;
2043 3491 t+=2;
2044 3491 f=0;
2045 3491 }
2046
2047 6158 break;
2048
2049 case right:
2050 5950 --t;
2051
2052
2/4
✓ Branch 0 taken 5950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5950 times.
5950 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2053 {
2054 wx=1;
2055 wy=13;
2056 f=2;
2057 }
2058 else
2059 {
2060 5950 wx=3;
2061 5950 wy=-15;
2062 5950 f=0;
2063 }
2064
2065
2/2
✓ Branch 0 taken 2585 times.
✓ Branch 1 taken 3365 times.
5950 if(attackclk>=7)
2066 {
2067 3365 wx+=15;
2068 3365 slashxofs+=1;
2069 3365 t = wpnsbuf[wpn2].tile;
2070 3365 cs2 = wpnsbuf[wpn2].csets&15;
2071
2072
2/4
✓ Branch 0 taken 3365 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3365 times.
3365 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2073 {
2074 wx-=1;
2075 wy-=2;
2076 }
2077 else
2078 {
2079 3365 t+=3;
2080 3365 f=0;
2081 3365 wy+=3;
2082 }
2083 3365 }
2084
2085 5950 break;
2086 }
2087 20831 }
2088
2089 412705 int32_t itemid2 = current_item_id(itype_chargering);
2090
2091
4/4
✓ Branch 0 taken 21741 times.
✓ Branch 1 taken 390964 times.
✓ Branch 2 taken 412173 times.
✓ Branch 3 taken 532 times.
412705 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2092 {
2093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2094 532 }
2095
2096 /*if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2097 {
2098 wy+=2;
2099 }*/
2100 412705 w->x = x+wx;
2101 412705 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2102 412705 w->z = (z+zofs);
2103 412705 w->tile = t;
2104 412705 w->flip = f;
2105 412705 w->power = weaponattackpower(itemid);
2106 412705 w->dir = dir;
2107 412705 w->doAutoRotate(true);
2108 412705 }
2109
2110 int HeroClass::getHammerState() const
2111 {
2112 if(attack == wHammer)
2113 {
2114 if(attackclk >= 15)
2115 return 3;
2116 if(attackclk >= 13)
2117 return 2;
2118 return 1;
2119 }
2120 return 0;
2121 }
2122
2123 7311715 void HeroClass::draw(BITMAP* dest)
2124 {
2125 /*{
2126 char buf[36];
2127 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2128 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2129 }*/
2130 7311715 int32_t oxofs = xofs, oyofs = yofs;
2131 7311715 bool shieldModify = false;
2132
2/2
✓ Branch 0 taken 7294653 times.
✓ Branch 1 taken 17062 times.
7311715 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2133
2134 {
2135
2/2
✓ Branch 0 taken 3180 times.
✓ Branch 1 taken 7308535 times.
7311715 if(action==dying)
2136 {
2137
2/2
✓ Branch 0 taken 2480 times.
✓ Branch 1 taken 700 times.
3180 if(!invisible)
2138 {
2139
1/2
✓ Branch 0 taken 700 times.
✗ Branch 1 not taken.
700 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2140 700 sprite::draw(dest);
2141 700 }
2142 3180 goto herodraw_end;
2143 }
2144
2145 7308535 bool useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2146
2147
2148
2/2
✓ Branch 0 taken 73318 times.
✓ Branch 1 taken 7235217 times.
7308535 if(!invisible)
2149
6/6
✓ Branch 0 taken 6291279 times.
✓ Branch 1 taken 943938 times.
✓ Branch 2 taken 3992931 times.
✓ Branch 3 taken 2298348 times.
✓ Branch 4 taken 170808 times.
✓ Branch 5 taken 3822123 times.
7235217 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2150
2151 // Stone of Agony
2152 7308535 bool agony=false;
2153 7308535 int32_t agonyid = current_item_id(itype_agony);
2154
2155
2/2
✓ Branch 0 taken 73318 times.
✓ Branch 1 taken 7235217 times.
7308535 if(!invisible)
2156 {
2157
2/2
✓ Branch 0 taken 6991403 times.
✓ Branch 1 taken 243814 times.
7235217 if(agonyid>-1)
2158 {
2159 243814 int32_t power=itemsbuf[agonyid].power;
2160 243814 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2161 243814 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2162 243814 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2163 243814 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2164
2165
2/2
✓ Branch 0 taken 243814 times.
✓ Branch 1 taken 243814 times.
487628 for(int32_t x=left; x<right; x+=16)
2166 {
2167
2/2
✓ Branch 0 taken 243782 times.
✓ Branch 1 taken 243814 times.
487596 for(int32_t y=top; y<bottom; y+=16)
2168 {
2169
4/4
✓ Branch 0 taken 243798 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 243782 times.
243814 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2170 {
2171 32 agony=true;
2172 32 x=right; // Break out of outer loop
2173 32 break;
2174 }
2175 243782 }
2176 243814 }
2177 243814 }
2178
2179 7235217 cs = 6;
2180
1/2
✓ Branch 0 taken 7235217 times.
✗ Branch 1 not taken.
7235217 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2181
2/2
✓ Branch 0 taken 1301062 times.
✓ Branch 1 taken 5934155 times.
7235217 if(!get_bit(quest_rules,qr_HEROFLICKER))
2182 {
2183
3/4
✓ Branch 0 taken 96072 times.
✓ Branch 1 taken 5838083 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96072 times.
5934155 if(superman && getCanFlicker())
2184 {
2185 96072 cs += (((~frame)>>1)&3);
2186 96072 }
2187
4/6
✓ Branch 0 taken 238844 times.
✓ Branch 1 taken 5599239 times.
✓ Branch 2 taken 238844 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 238844 times.
5838083 else if(hclk&&(DivineProtectionShieldClk<=0) && getCanFlicker())
2188 {
2189 238844 cs += ((hclk>>1)&3);
2190 238844 }
2191 5934155 }
2192 7235217 }
2193
2194
5/6
✓ Branch 0 taken 6536455 times.
✓ Branch 1 taken 772080 times.
✓ Branch 2 taken 6530653 times.
✓ Branch 3 taken 5802 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6530653 times.
7308535 if(attackclk || (action==attacking||action==sideswimattacking))
2195 {
2196 /* Spaghetti code constants!
2197 * - Hero.attack contains a weapon type...
2198 * - which must be converted to an itype...
2199 * - which must be converted to an item ID...
2200 * - which is used to acquire a wpn ID! Aack!
2201 */
2202
8/8
✓ Branch 0 taken 12859 times.
✓ Branch 1 taken 765023 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 764995 times.
✓ Branch 4 taken 21498 times.
✓ Branch 5 taken 743497 times.
✓ Branch 6 taken 22079 times.
✓ Branch 7 taken 721418 times.
777882 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2203
4/4
✓ Branch 0 taken 29427 times.
✓ Branch 1 taken 748455 times.
✓ Branch 2 taken 907 times.
✓ Branch 3 taken 28520 times.
777882 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2204 777882 itemid=vbound(itemid, 0, MAXITEMS-1);
2205 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2206
7/8
✓ Branch 0 taken 250896 times.
✓ Branch 1 taken 526986 times.
✓ Branch 2 taken 250896 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162480 times.
✓ Branch 5 taken 88416 times.
✓ Branch 6 taken 13550 times.
✓ Branch 7 taken 148930 times.
777882 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2207 {
2208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540536 times.
540536 if(attack == wBugNet)
2209 {
2210 weapon *w=NULL;
2211 bool found = false;
2212 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2213 {
2214 w = (weapon*)Lwpns.spr(q);
2215 if(w->id == wBugNet)
2216 {
2217 found = true;
2218 break;
2219 }
2220 }
2221 if(!found)
2222 {
2223 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2224
2225 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2226 }
2227 positionNet(w, itemid);
2228 }
2229
8/8
✓ Branch 0 taken 133070 times.
✓ Branch 1 taken 407466 times.
✓ Branch 2 taken 117716 times.
✓ Branch 3 taken 15354 times.
✓ Branch 4 taken 108841 times.
✓ Branch 5 taken 8875 times.
✓ Branch 6 taken 117696 times.
✓ Branch 7 taken 422840 times.
540536 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2230 {
2231 // Create a sword weapon at the right spot.
2232 422840 weapon *w=NULL;
2233 422840 bool found = false;
2234
2235 // Look for pre-existing sword
2236
2/2
✓ Branch 0 taken 41316 times.
✓ Branch 1 taken 488681 times.
529997 for(int32_t i=0; i<Lwpns.Count(); i++)
2237 {
2238 488681 w = (weapon*)Lwpns.spr(i);
2239
2240
2/2
✓ Branch 0 taken 107157 times.
✓ Branch 1 taken 381524 times.
488681 if(w->id == (attack==wSword ? wSword : wWand))
2241 {
2242 381524 found = true;
2243 381524 break;
2244 }
2245 107157 }
2246
2247
2/2
✓ Branch 0 taken 381524 times.
✓ Branch 1 taken 41316 times.
422840 if(!found) // Create one if sword nonexistant
2248 {
2249
5/10
✓ Branch 0 taken 41316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41316 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41316 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41316 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 41316 times.
✗ Branch 9 not taken.
41316 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2250 41316 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2251
2252 41316 positionSword(w,itemid);
2253
2254 // Stone of Agony
2255
1/2
✓ Branch 0 taken 41316 times.
✗ Branch 1 not taken.
41316 if(agony)
2256 {
2257 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2258 }
2259 41316 }
2260
2261 // These are set by positionSword(), above or in checkstab()
2262 422840 yofs += slashyofs;
2263 422840 xofs += slashxofs;
2264 422840 slashyofs = slashxofs = 0;
2265 422840 }
2266 540536 }
2267
2268 777882 if(attackclk<7
2269
4/4
✓ Branch 0 taken 412220 times.
✓ Branch 1 taken 365662 times.
✓ Branch 2 taken 313951 times.
✓ Branch 3 taken 98269 times.
777882 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2270
4/6
✓ Branch 0 taken 72650 times.
✓ Branch 1 taken 241301 times.
✓ Branch 2 taken 72650 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72650 times.
313951 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2271
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 70837 times.
72650 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2272
4/4
✓ Branch 0 taken 158442 times.
✓ Branch 1 taken 10664 times.
✓ Branch 2 taken 151559 times.
✓ Branch 3 taken 6883 times.
170919 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2273
4/4
✓ Branch 0 taken 12929 times.
✓ Branch 1 taken 156177 times.
✓ Branch 2 taken 17518 times.
✓ Branch 3 taken 138659 times.
169106 || (attack==wHammer && attackclk<=30)
2274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138659 times.
156177 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2275 {
2276
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 639140 times.
639223 if(!invisible)
2277 {
2278 639140 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2279
2/4
✓ Branch 0 taken 639140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 639140 times.
✗ Branch 3 not taken.
639140 if (FIXED_Z3_ANIMATION)
2280 {
2281 if (attackclk >= 2) tile += (extend==2?2:1);
2282 if (attackclk >= 13) tile += (extend==2?2:1);
2283 }
2284
2285
14/18
✓ Branch 0 taken 58820 times.
✓ Branch 1 taken 580320 times.
✓ Branch 2 taken 13042 times.
✓ Branch 3 taken 45778 times.
✓ Branch 4 taken 5786 times.
✓ Branch 5 taken 7256 times.
✓ Branch 6 taken 4967 times.
✓ Branch 7 taken 819 times.
✓ Branch 8 taken 41380 times.
✓ Branch 9 taken 17440 times.
✓ Branch 10 taken 23147 times.
✓ Branch 11 taken 18233 times.
✓ Branch 12 taken 23147 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 23147 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
639140 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2286 {
2287 18233 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2288
2/4
✓ Branch 0 taken 18233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18233 times.
✗ Branch 3 not taken.
18233 if (FIXED_Z3_ANIMATION)
2289 {
2290 if (attackclk >= 7) tile += (extend==2?2:1);
2291 if (attackclk >= 11) tile += (extend==2?2:1);
2292 if (attackclk >= 14) tile += (extend==2?2:1);
2293 }
2294 18233 }
2295
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 639140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
639140 if (attack==wBugNet && !get_bit(quest_rules, qr_OLD_BUG_NET))
2296 {
2297 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2298 {
2299 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2300 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2301 }
2302 else
2303 {
2304 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2305 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2306 }
2307 }
2308
2309
4/4
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 617061 times.
✓ Branch 2 taken 13029 times.
✓ Branch 3 taken 9050 times.
639140 if((attack==wHammer) && (attackclk<13))
2310 {
2311 9050 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2312
2/4
✓ Branch 0 taken 9050 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9050 times.
✗ Branch 3 not taken.
9050 if (FIXED_Z3_ANIMATION)
2313 {
2314 if (attackclk >= 14) tile += (extend==2?2:1);
2315 if (attackclk >= 16) tile += (extend==2?2:1);
2316 }
2317 9050 }
2318
2319
2/2
✓ Branch 0 taken 586541 times.
✓ Branch 1 taken 52599 times.
639140 if(useltm)
2320 {
2321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52599 times.
52599 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2322 52599 }
2323
2324 // Stone of Agony
2325
1/2
✓ Branch 0 taken 639140 times.
✗ Branch 1 not taken.
639140 if(agony)
2326 {
2327 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2328 }
2329
2330 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2331
2332 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2333
6/6
✓ Branch 0 taken 137706 times.
✓ Branch 1 taken 501434 times.
✓ Branch 2 taken 134100 times.
✓ Branch 3 taken 3606 times.
✓ Branch 4 taken 11476 times.
✓ Branch 5 taken 126230 times.
639140 if (!(get_bit(quest_rules, qr_HEROFLICKER) && ((superman || hclk) && (frame & 1))))
2334 {
2335 627664 masked_draw(dest);
2336 627664 }
2337
2338 //Prevent flickering -Z
2339
1/2
✓ Branch 0 taken 639140 times.
✗ Branch 1 not taken.
639140 if (!getCanFlicker()) masked_draw(dest);
2340 639140 }
2341
2342
2/2
✓ Branch 0 taken 617144 times.
✓ Branch 1 taken 22079 times.
639223 if(attack!=wHammer)
2343 617144 goto herodraw_end;
2344 22079 }
2345
2346
2/2
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 138659 times.
160738 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2347 {
2348 22079 int32_t wy=1;
2349 22079 int32_t wx=1;
2350 22079 int32_t f=0,t,cs2;
2351 22079 weapon *w=NULL;
2352 22079 bool found = false;
2353
2354
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 21549 times.
22314 for(int32_t i=0; i<Lwpns.Count(); i++)
2355 {
2356 21549 w = (weapon*)Lwpns.spr(i);
2357
2358
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 21314 times.
21549 if(w->id == wHammer)
2359 {
2360 21314 found = true;
2361 21314 break;
2362 }
2363 235 }
2364
2365
2/2
✓ Branch 0 taken 21314 times.
✓ Branch 1 taken 765 times.
22079 if(!found)
2366 {
2367
5/10
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 765 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 765 times.
✗ Branch 9 not taken.
765 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2368 765 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2369 765 found = true;
2370 765 }
2371
2372 22079 t = w->o_tile;
2373 22079 cs2 = w->o_cset;
2374
2375
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3412 times.
✓ Branch 2 taken 4870 times.
✓ Branch 3 taken 6386 times.
✓ Branch 4 taken 7411 times.
22079 switch(dir)
2376 {
2377 case up:
2378 3412 wx=-1;
2379 3412 wy=-15;
2380
1/2
✓ Branch 0 taken 3412 times.
✗ Branch 1 not taken.
3412 if (IsSideSwim())wy+=hammer_swim_up_offset;
2381
2382
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 2010 times.
3412 if(attackclk>=13)
2383 {
2384 2010 wx-=1;
2385 2010 wy+=1;
2386 2010 ++t;
2387 2010 }
2388
2389
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1778 times.
3412 if(attackclk>=15)
2390 {
2391
1/2
✓ Branch 0 taken 1778 times.
✗ Branch 1 not taken.
1778 if (IsSideSwim())wy-=hammer_swim_up_offset;
2392 1778 ++t;
2393 1778 }
2394
2395 3412 break;
2396
2397 case down:
2398 4870 wx=3;
2399 4870 wy=-14;
2400
1/2
✓ Branch 0 taken 4870 times.
✗ Branch 1 not taken.
4870 if (IsSideSwim())wy+=hammer_swim_down_offset;
2401 4870 t+=3;
2402
2403
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 2849 times.
4870 if(attackclk>=13)
2404 {
2405 2849 wy+=16;
2406 2849 ++t;
2407 2849 }
2408
2409
2/2
✓ Branch 0 taken 2344 times.
✓ Branch 1 taken 2526 times.
4870 if(attackclk>=15)
2410 {
2411 2526 wx-=1;
2412 2526 wy+=12;
2413
1/2
✓ Branch 0 taken 2526 times.
✗ Branch 1 not taken.
2526 if (IsSideSwim())wy-=hammer_swim_down_offset;
2414 2526 ++t;
2415 2526 }
2416
2417 4870 break;
2418
2419 case left:
2420 6386 wx=0;
2421 6386 wy=-14;
2422
1/2
✓ Branch 0 taken 6386 times.
✗ Branch 1 not taken.
6386 if (IsSideSwim())wy+=hammer_swim_left_offset;
2423 6386 t+=6;
2424 6386 f=1;
2425
2426
2/2
✓ Branch 0 taken 2562 times.
✓ Branch 1 taken 3824 times.
6386 if(attackclk>=13)
2427 {
2428 3824 wx-=7;
2429 3824 wy+=8;
2430 3824 ++t;
2431 3824 }
2432
2433
2/2
✓ Branch 0 taken 2986 times.
✓ Branch 1 taken 3400 times.
6386 if(attackclk>=15)
2434 {
2435 3400 wx-=8;
2436 3400 wy+=8;
2437
1/2
✓ Branch 0 taken 3400 times.
✗ Branch 1 not taken.
3400 if (IsSideSwim())wy-=hammer_swim_left_offset;
2438 3400 ++t;
2439 3400 }
2440
2441 6386 break;
2442
2443 case right:
2444 7411 wx=0;
2445 7411 wy=-14;
2446
1/2
✓ Branch 0 taken 7411 times.
✗ Branch 1 not taken.
7411 if (IsSideSwim())wy+=hammer_swim_right_offset;
2447 7411 t+=6;
2448
2449
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 4346 times.
7411 if(attackclk>=13)
2450 {
2451 4346 wx+=7;
2452 4346 wy+=8;
2453 4346 ++t;
2454 4346 }
2455
2456
2/2
✓ Branch 0 taken 3558 times.
✓ Branch 1 taken 3853 times.
7411 if(attackclk>=15)
2457 {
2458 3853 wx+=8;
2459 3853 wy+=8;
2460
1/2
✓ Branch 0 taken 3853 times.
✗ Branch 1 not taken.
3853 if (IsSideSwim())wy-=hammer_swim_right_offset;
2461 3853 ++t;
2462 3853 }
2463
2464 7411 break;
2465 }
2466
2467
7/8
✓ Branch 0 taken 21929 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 18085 times.
✓ Branch 3 taken 3844 times.
✓ Branch 4 taken 18085 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1927 times.
✓ Branch 7 taken 16158 times.
22079 if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2468 {
2469 16308 wy+=2;
2470 16308 }
2471
2472 // Stone of Agony
2473
1/2
✓ Branch 0 taken 22079 times.
✗ Branch 1 not taken.
22079 if(agony)
2474 {
2475 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2476 }
2477
2478 22079 w->x = x+wx;
2479 22079 w->y = y+wy-(54-yofs)-fakez;
2480 22079 w->z = (z+zofs);
2481 22079 w->tile = t;
2482 22079 w->flip = f;
2483 22079 w->hit_width=20;
2484 22079 w->hit_height=20;
2485
2486
2/2
✓ Branch 0 taken 13797 times.
✓ Branch 1 taken 8282 times.
22079 if(dir>down)
2487 {
2488 13797 w->hit_height-=6;
2489 13797 }
2490 else
2491 {
2492 8282 w->hit_width-=6;
2493 8282 w->hyofs=4;
2494 }
2495
2496 22079 w->power = weaponattackpower(itemid);
2497
2498
7/10
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 21345 times.
✓ Branch 2 taken 734 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 734 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 732 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
22079 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2499 {
2500
3/4
✓ Branch 0 taken 722 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 734 times.
✗ Branch 3 not taken.
734 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_bit(quest_rules,qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2501 734 }
2502
2503 22079 goto herodraw_end;
2504 }
2505 138659 }
2506
2/4
✓ Branch 0 taken 6530653 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6530653 times.
6530653 else if(!charging && !spins) // remove the sword
2507 {
2508
2/2
✓ Branch 0 taken 1720699 times.
✓ Branch 1 taken 6530653 times.
8251352 for(int32_t i=0; i<Lwpns.Count(); i++)
2509 {
2510 1720699 weapon *w = (weapon*)Lwpns.spr(i);
2511
2512
6/6
✓ Branch 0 taken 1719925 times.
✓ Branch 1 taken 774 times.
✓ Branch 2 taken 1719815 times.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 17390 times.
✓ Branch 5 taken 1702425 times.
1720699 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2513 18274 w->dead=1;
2514 1720699 }
2515 6530653 }
2516
2517
2/2
✓ Branch 0 taken 73235 times.
✓ Branch 1 taken 6596077 times.
6669312 if(invisible)
2518 {
2519 73235 goto herodraw_end;
2520 }
2521
2522
2/4
✓ Branch 0 taken 6596077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6596077 times.
6596077 if(action != casting && action != sideswimcasting)
2523 {
2524 // Keep this consistent with checkspecial2, line 7800-ish...
2525
6/6
✓ Branch 0 taken 156063 times.
✓ Branch 1 taken 6440014 times.
✓ Branch 2 taken 149274 times.
✓ Branch 3 taken 6789 times.
✓ Branch 4 taken 7213 times.
✓ Branch 5 taken 142061 times.
6596077 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2526
2527 6596077 int32_t jumping2 = int32_t(jumping*((zinit.gravity2 / 100)/16.0));
2528 6596077 bool noliftspr = get_bit(quest_rules,qr_NO_LIFT_SPRITE);
2529 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2530
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6152249 times.
✓ Branch 3 taken 443828 times.
6596077 switch(zinit.heroAnimationStyle)
2531 {
2532 case las_original: //normal
2533
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 6152185 times.
6152249 if(action==drowning)
2534 {
2535
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(inwater)
2536 {
2537 64 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2539 64 }
2540 else
2541 {
2542 goto herodraw_end;
2543 }
2544 64 }
2545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6152185 times.
6152185 else if(action==lavadrowning)
2546 {
2547 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2548 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2549 }
2550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6152185 times.
6152185 else if(action==sidedrowning)
2551 {
2552 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2553 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2554 }
2555
2/4
✓ Branch 0 taken 6152185 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6152185 times.
6152185 else if (action == sideswimming || action == sideswimhit)
2556 {
2557 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2558
2559 if(lstep>=6)
2560 {
2561 if(dir==up)
2562 {
2563 if ( script_hero_sprite <= 0 ) ++flip;
2564 }
2565 else
2566 {
2567 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2568 }
2569 }
2570 }
2571
5/6
✓ Branch 0 taken 6080748 times.
✓ Branch 1 taken 71437 times.
✓ Branch 2 taken 6080228 times.
✓ Branch 3 taken 520 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6080228 times.
6152185 else if(action==swimming || action==swimhit || hopclk==0xFF)
2572 {
2573 71957 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2574
2575
2/2
✓ Branch 0 taken 35932 times.
✓ Branch 1 taken 36025 times.
71957 if(lstep>=6)
2576 {
2577
2/2
✓ Branch 0 taken 7125 times.
✓ Branch 1 taken 28900 times.
36025 if(dir==up)
2578 {
2579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7125 times.
7125 if ( script_hero_sprite <= 0 ) ++flip;
2580 7125 }
2581 else
2582 {
2583
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28900 times.
28900 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2584 }
2585 36025 }
2586
2587
2/2
✓ Branch 0 taken 68768 times.
✓ Branch 1 taken 3189 times.
71957 if(isDiving())
2588 {
2589 3189 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3189 times.
3189 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2591 3189 }
2592 71957 }
2593
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 6078610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
6080228 else if(charging > 0 && attack != wHammer)
2594 {
2595 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2596
2597
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2598 {
2599
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2600 {
2601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( script_hero_sprite <= 0 ) ++flip;
2602 144 }
2603 else
2604 {
2605
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2606 }
2607 675 }
2608 1618 }
2609
9/12
✓ Branch 0 taken 6078368 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 6078368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85805 times.
✓ Branch 5 taken 5992805 times.
✓ Branch 6 taken 71761 times.
✓ Branch 7 taken 14044 times.
✓ Branch 8 taken 71761 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 71761 times.
6078610 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2610 {
2611 71761 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71761 times.
71761 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2613 71761 }
2614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6006849 times.
6006849 else if(fallclk>0)
2615 {
2616 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2617 if ( script_hero_sprite <= 0 ) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2618 }
2619
3/6
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 6006233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 616 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6006849 else if(!noliftspr&&action==lifting&&isLifting())
2620 {
2621 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2622 if(script_hero_sprite <= 0)
2623 {
2624 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2625 auto speed = tliftclk/frames;
2626 if (speed < 1) speed = 1;
2627 auto curframe = (tliftclk - liftclk) / speed;
2628 if (!tliftclk) curframe = frames - 1;
2629 if(unsigned(curframe) < frames)
2630 tile += curframe * (extend == 2 ? 2 : 1);
2631 }
2632 }
2633 else
2634 {
2635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6006849 times.
6006849 if(IsSideSwim())
2636 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2637
3/4
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 6006233 times.
✓ Branch 2 taken 616 times.
✗ Branch 3 not taken.
6006849 else if(!noliftspr&&isLifting())
2638 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2639 6006849 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2640
2641
2/2
✓ Branch 0 taken 4495469 times.
✓ Branch 1 taken 1511380 times.
6006849 if(dir>up)
2642 {
2643 4495469 useltm=true;
2644 4495469 shieldModify=true;
2645 4495469 }
2646
2647
2/2
✓ Branch 0 taken 2932163 times.
✓ Branch 1 taken 3074686 times.
6006849 if(lstep>=6)
2648 {
2649
2/2
✓ Branch 0 taken 763979 times.
✓ Branch 1 taken 2310707 times.
3074686 if(dir==up)
2650 {
2651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763979 times.
763979 if ( script_hero_sprite <= 0 ) ++flip;
2652 763979 }
2653 else
2654 {
2655
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2310707 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2310707 times.
2310707 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2656 }
2657 3074686 }
2658 }
2659
2660 6152249 break;
2661
2662 case las_bszelda: //BS
2663
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 443316 times.
443828 if(action==drowning)
2664 {
2665
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(inwater)
2666 {
2667 512 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2669 512 }
2670 else
2671 {
2672 goto herodraw_end;
2673 }
2674 512 }
2675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443316 times.
443316 else if (action == sidedrowning)
2676 {
2677 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2678 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2679 }
2680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443316 times.
443316 else if(action==lavadrowning)
2681 {
2682 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2683 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2684 }
2685
2/4
✓ Branch 0 taken 443316 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 443316 times.
443316 else if (action == sideswimming || action == sideswimhit)
2686 {
2687 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2688
2689 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2690 }
2691
4/6
✓ Branch 0 taken 440550 times.
✓ Branch 1 taken 2766 times.
✓ Branch 2 taken 440550 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 440550 times.
443316 else if(action==swimming || action==swimhit || hopclk==0xFF)
2692 {
2693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2766 times.
2766 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2694 {
2695 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2696 }
2697 else
2698 {
2699 2766 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2700 }
2701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2766 times.
2766 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2702
2703
2/2
✓ Branch 0 taken 2405 times.
✓ Branch 1 taken 361 times.
2766 if(isDiving())
2704 {
2705
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2706 {
2707 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2708 }
2709 else
2710 {
2711 361 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2712 }
2713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 361 times.
361 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2714 361 }
2715 2766 }
2716
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 440550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
440550 else if(charging > 0 && attack != wHammer)
2717 {
2718 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2719 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2720 }
2721
8/10
✓ Branch 0 taken 436795 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 436795 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1004 times.
✓ Branch 5 taken 439546 times.
✓ Branch 6 taken 754 times.
✓ Branch 7 taken 250 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 754 times.
440550 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2722 {
2723 754 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 754 times.
754 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2725 754 }
2726
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 439306 times.
439796 else if(fallclk>0)
2727 {
2728 490 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if ( script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2730 490 }
2731
5/6
✓ Branch 0 taken 16696 times.
✓ Branch 1 taken 422610 times.
✓ Branch 2 taken 199 times.
✓ Branch 3 taken 16497 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 199 times.
439306 else if(!noliftspr&&action==lifting&&isLifting())
2732 {
2733 199 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
199 if(script_hero_sprite <= 0)
2735 {
2736 199 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2737 199 auto speed = tliftclk/frames;
2738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
199 if (speed < 1) speed = 1;
2739 199 auto curframe = (tliftclk - liftclk) / speed;
2740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
199 if (!tliftclk) curframe = frames - 1;
2741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
199 if(unsigned(curframe) < frames)
2742 199 tile += curframe * (extend == 2 ? 2 : 1);
2743 199 }
2744 199 }
2745 else
2746 {
2747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439107 times.
439107 if(IsSideSwim())
2748 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2749
4/4
✓ Branch 0 taken 16497 times.
✓ Branch 1 taken 422610 times.
✓ Branch 2 taken 15431 times.
✓ Branch 3 taken 1066 times.
439107 else if(!noliftspr&&isLifting())
2750 1066 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2751 438041 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2752
2753
2/2
✓ Branch 0 taken 134862 times.
✓ Branch 1 taken 304245 times.
439107 if(dir>up)
2754 {
2755 304245 useltm=true;
2756 304245 shieldModify=true;
2757 304245 }
2758
2759 /*
2760 else if (dir==up)
2761 {
2762 useltm=true;
2763 }
2764 */
2765
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 436547 times.
439107 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2766 }
2767
2768 443828 break;
2769
2770 case las_zelda3slow: //8-frame Zelda 3 (slow)
2771 case las_zelda3: //8-frame Zelda 3
2772 if(action == drowning)
2773 {
2774 if(inwater)
2775 {
2776 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2777 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2778 }
2779 else
2780 {
2781 goto herodraw_end;
2782 }
2783 }
2784 else if(action == lavadrowning)
2785 {
2786 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2787 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2788
2789 }
2790 else if(action == sidedrowning)
2791 {
2792 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2793 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2794 }
2795 else if (action == sideswimming || action == sideswimhit)
2796 {
2797 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2798
2799 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2800 }
2801 else if(action == swimming || action==swimhit || hopclk==0xFF)
2802 {
2803 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2804 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2805
2806 if(isDiving())
2807 {
2808 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2809 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2810 }
2811 }
2812 else if(charging > 0 && attack != wHammer)
2813 {
2814 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2815 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2816 //int32_t l=hero_count/hero_animation_speed;
2817 int32_t l=(hero_count/hero_animation_speed)&15;
2818 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2819 l-=((l>3)?1:0)+((l>12)?1:0);
2820 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2821 }
2822 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2823 {
2824 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2825 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2826 }
2827 else if(fallclk>0)
2828 {
2829 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2830 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2831 }
2832 else if(!noliftspr&&action==lifting&&isLifting())
2833 {
2834 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2835 if(script_hero_sprite <= 0)
2836 {
2837 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2838 auto speed = tliftclk/frames;
2839 if (speed < 1) speed = 1;
2840 auto curframe = (tliftclk-liftclk)/speed;
2841 if (!tliftclk) curframe = frames - 1;
2842 if(unsigned(curframe) < frames)
2843 tile += curframe * (extend == 2 ? 2 : 1);
2844 }
2845 }
2846 else
2847 {
2848 if(IsSideSwim())
2849 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2850 else if(!noliftspr&&isLifting())
2851 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2852 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2853
2854 if(action == walking || action == climbcoverbottom || action == climbcovertop)
2855 {
2856 if (script_hero_sprite <= 0 ) tile += (extend == 2 ? 2 : 1);
2857 }
2858
2859 if(dir>up)
2860 {
2861 useltm=true;
2862 shieldModify=true;
2863 }
2864
2865 if(action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop)
2866 {
2867 //tile+=(extend==2?2:1);
2868 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
2869 int32_t l = hero_count / hero_animation_speed;
2870 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
2871 if (script_hero_sprite <= 0 ) tile += (l / 2) * (extend == 2 ? 2 : 1);
2872 }
2873 }
2874
2875 break;
2876
2877 default:
2878 break;
2879 }
2880 6596077 }
2881
2882
6/6
✓ Branch 0 taken 5704738 times.
✓ Branch 1 taken 891339 times.
✓ Branch 2 taken 3536816 times.
✓ Branch 3 taken 2167922 times.
✓ Branch 4 taken 158886 times.
✓ Branch 5 taken 3377930 times.
6596077 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2883
2884
2/2
✓ Branch 0 taken 6593140 times.
✓ Branch 1 taken 2937 times.
6596077 if(action==won)
2885 {
2886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2937 times.
2937 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
2887 2937 }
2888
2889
4/4
✓ Branch 0 taken 6550658 times.
✓ Branch 1 taken 45419 times.
✓ Branch 2 taken 48991 times.
✓ Branch 3 taken 6501667 times.
6596077 if(action==landhold1 || action==landhold2)
2890 {
2891 94410 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2892
6/6
✓ Branch 0 taken 80134 times.
✓ Branch 1 taken 14276 times.
✓ Branch 2 taken 59609 times.
✓ Branch 3 taken 20525 times.
✓ Branch 4 taken 13567 times.
✓ Branch 5 taken 46042 times.
94410 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2893 94410 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
2894 94410 }
2895
4/4
✓ Branch 0 taken 6501017 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 6500887 times.
6501667 else if(action==waterhold1 || action==waterhold2)
2896 {
2897 780 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2898 780 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
2899 780 }
2900
2/4
✓ Branch 0 taken 6500887 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6500887 times.
6500887 else if(action==sidewaterhold1 || action==sidewaterhold2)
2901 {
2902 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2903 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
2904 }
2905
2906
2/4
✓ Branch 0 taken 6596077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6596077 times.
6596077 if(action!=casting && action!=sideswimcasting)
2907 {
2908
2/2
✓ Branch 0 taken 1583566 times.
✓ Branch 1 taken 5012511 times.
6596077 if(useltm)
2909 {
2910
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 5009951 times.
5012511 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
2911 5012511 }
2912 6596077 }
2913
2914 // Stone of Agony
2915
2/2
✓ Branch 0 taken 6596045 times.
✓ Branch 1 taken 32 times.
6596077 if(agony)
2916 {
2917
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2918 32 }
2919
2920
6/6
✓ Branch 0 taken 1163356 times.
✓ Branch 1 taken 5432721 times.
✓ Branch 2 taken 1108839 times.
✓ Branch 3 taken 54517 times.
✓ Branch 4 taken 59060 times.
✓ Branch 5 taken 1104296 times.
6596077 if(!(get_bit(quest_rules,qr_HEROFLICKER)&&((superman||hclk)&&(frame&1))))
2921 {
2922 6537017 masked_draw(dest);
2923 6537017 }
2924
2925 //draw held items after Hero so they don't go behind his head
2926
4/4
✓ Branch 0 taken 6550658 times.
✓ Branch 1 taken 45419 times.
✓ Branch 2 taken 48991 times.
✓ Branch 3 taken 6501667 times.
6596077 if(action==landhold1 || action==landhold2)
2927 {
2928
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 94394 times.
94410 if(holditem > -1)
2929 {
2930
2/2
✓ Branch 0 taken 44580 times.
✓ Branch 1 taken 49814 times.
94394 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2931 {
2932 44580 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2933 44580 }
2934 else
2935 {
2936 49814 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2937 }
2938 94394 }
2939 94410 }
2940
4/4
✓ Branch 0 taken 6501017 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 6500887 times.
6501667 else if(action==waterhold1 || action==waterhold2)
2941 {
2942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(holditem > -1)
2943 {
2944
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 260 times.
780 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2945 {
2946 520 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2947 520 }
2948 else
2949 {
2950 260 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2951 }
2952 780 }
2953 780 }
2954
2/4
✓ Branch 0 taken 6500887 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6500887 times.
6500887 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
2955 {
2956 if(holditem > -1)
2957 {
2958 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2959 {
2960 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2961 }
2962 else
2963 {
2964 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2965 }
2966 }
2967 }
2968
4/4
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 6579716 times.
✓ Branch 2 taken 3393 times.
✓ Branch 3 taken 12968 times.
6596077 if(fairyclk==0||(get_bit(quest_rules,qr_NOHEARTRING)))
2969 {
2970 6583109 goto herodraw_end;
2971 }
2972
2973 12968 double a2 = fairyclk*int64_t(2)*PI/80 + (PI/2);
2974 12968 int32_t hearts=0;
2975 // int32_t htile = QHeader.dat_flags[ZQ_TILES] ? 2 : 0;
2976 12968 int32_t htile = 2;
2977
2978 12968 do
2979 {
2980 80784 int32_t nx=125;
2981
2982
2/2
✓ Branch 0 taken 56544 times.
✓ Branch 1 taken 24240 times.
80784 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2983 {
2984 24240 nx=x;
2985 24240 }
2986
2987 80784 int32_t ny=88;
2988
2989
2/2
✓ Branch 0 taken 56544 times.
✓ Branch 1 taken 24240 times.
80784 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2990 {
2991 24240 ny=y;
2992 24240 }
2993
2994 80784 double tx = zc::math::Cos(a2)*53 +nx;
2995 80784 double ty = -zc::math::Sin(a2)*53 +ny+playing_field_offset;
2996 80784 overtile8(dest,htile,int32_t(tx),int32_t(ty),1,0);
2997 80784 a2-=PI/4;
2998 80784 ++hearts;
2999
2/2
✓ Branch 0 taken 67816 times.
✓ Branch 1 taken 12968 times.
161568 }
3000
2/2
✓ Branch 0 taken 6560 times.
✓ Branch 1 taken 74224 times.
80784 while(a2>PI/2 && hearts<8);
3001 12968 }
3002 herodraw_end:
3003 7311715 xofs=oxofs;
3004 7311715 yofs=oyofs;
3005 7311715 do_primitives(dest, SPLAYER_PLAYER_DRAW, tmpscr, 0, playing_field_offset);
3006 7311715 }
3007
3008 7164681 void HeroClass::masked_draw(BITMAP* dest)
3009 {
3010 7164681 zfix lz, lfz;
3011
2/2
✓ Branch 0 taken 7163416 times.
✓ Branch 1 taken 1265 times.
7164681 if(lift_wpn)
3012 {
3013 1265 lz = lift_wpn->z;
3014 1265 lfz = lift_wpn->fakez;
3015 1265 }
3016
3017
12/12
✓ Branch 0 taken 3956498 times.
✓ Branch 1 taken 3208183 times.
✓ Branch 2 taken 3786476 times.
✓ Branch 3 taken 170022 times.
✓ Branch 4 taken 3736182 times.
✓ Branch 5 taken 50294 times.
✓ Branch 6 taken 3682105 times.
✓ Branch 7 taken 54077 times.
✓ Branch 8 taken 3604662 times.
✓ Branch 9 taken 77443 times.
✓ Branch 10 taken 3642720 times.
✓ Branch 11 taken 143756 times.
7164681 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_bit(quest_rules,qr_FREEFORM))
3018 {
3019 // clip under doorways
3020 143756 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
3021
3022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143756 times.
143756 if(sub!=NULL)
3023 {
3024 143756 yofs -= (playing_field_offset+16);
3025 143756 xofs -= 16;
3026 143756 sprite::draw(sub);
3027
1/2
✓ Branch 0 taken 143756 times.
✗ Branch 1 not taken.
143756 if(lift_wpn)
3028 {
3029 handle_lift(false);
3030 bool shad = lift_wpn->has_shadow;
3031 lift_wpn->has_shadow = false;
3032 lift_wpn->z += z;
3033 lift_wpn->fakez += fakez;
3034 lift_wpn->draw(sub);
3035 lift_wpn->has_shadow = shad;
3036 }
3037 143756 prompt_draw(sub);
3038 143756 xofs+=16;
3039 143756 yofs += (playing_field_offset+16);
3040 143756 destroy_bitmap(sub);
3041 143756 }
3042 143756 }
3043 else
3044 {
3045 7020925 sprite::draw(dest);
3046
2/2
✓ Branch 0 taken 7019660 times.
✓ Branch 1 taken 1265 times.
7020925 if(lift_wpn)
3047 {
3048 1265 handle_lift(false);
3049 1265 bool shad = lift_wpn->has_shadow;
3050 1265 lift_wpn->has_shadow = false;
3051 1265 lift_wpn->z += z;
3052 1265 lift_wpn->fakez += fakez;
3053 1265 lift_wpn->draw(dest);
3054 1265 lift_wpn->has_shadow = shad;
3055 1265 }
3056 7020925 prompt_draw(dest);
3057 }
3058
3059
2/2
✓ Branch 0 taken 7163416 times.
✓ Branch 1 taken 1265 times.
7164681 if(lift_wpn)
3060 {
3061 1265 lift_wpn->z = lz;
3062 1265 lift_wpn->fakez = lfz;
3063 1265 }
3064 7164681 return;
3065 }
3066 7164681 void HeroClass::prompt_draw(BITMAP* dest)
3067 {
3068
2/2
✓ Branch 0 taken 7162632 times.
✓ Branch 1 taken 2049 times.
7164681 if(!prompt_combo) return;
3069 2049 int32_t sx = real_x(x+xofs+prompt_x);
3070 2049 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3071 2049 sy -= fake_z(fakez);
3072 2049 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3073 2049 return;
3074 7164681 }
3075
3076 9359 void collectitem_script(int32_t id)
3077 {
3078
2/2
✓ Branch 0 taken 9245 times.
✓ Branch 1 taken 114 times.
9359 if(itemsbuf[id].collect_script)
3079 {
3080 //clear item script stack.
3081 114 FFCore.ref(ScriptType::Item, -id).Clear();
3082
3083
2/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if ( id > 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3084 {
3085 114 int i = -id;
3086 114 FFCore.reset_script_engine_data(ScriptType::Item, i);
3087 114 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3088 114 FFCore.deallocateAllArrays(ScriptType::Item, i);
3089 114 }
3090 else if (id == 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3091 {
3092 int i = COLLECT_SCRIPT_ITEM_ZERO;
3093 FFCore.reset_script_engine_data(ScriptType::Item, i);
3094 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3095 FFCore.deallocateAllArrays(ScriptType::Item, i);
3096 }
3097 //runningItemScripts[id] = 0;
3098 114 }
3099 9359 }
3100 935 void passiveitem_script(int32_t id, bool doRun = false)
3101 {
3102 //Passive item scripts on colelction
3103
3/6
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 908 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
935 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING)) ))
3104 {
3105 FFCore.reset_script_engine_data(ScriptType::Item, id);
3106
3107 if(get_bit(quest_rules,qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3108 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3109 {
3110 FFCore.doscript(ScriptType::Item, id) = false;
3111 return;
3112 }
3113 if(doRun)
3114 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].script, id);
3115 }
3116 935 }
3117
3118 // separate case for sword/wand/hammer/slashed weapons only
3119 // the main weapon checking is in the global function check_collisions()
3120 6406142 bool HeroClass::checkstab()
3121 {
3122
14/14
✓ Branch 0 taken 5642667 times.
✓ Branch 1 taken 763475 times.
✓ Branch 2 taken 207362 times.
✓ Branch 3 taken 556113 times.
✓ Branch 4 taken 186080 times.
✓ Branch 5 taken 21282 times.
✓ Branch 6 taken 164001 times.
✓ Branch 7 taken 22079 times.
✓ Branch 8 taken 163973 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 151171 times.
✓ Branch 11 taken 12802 times.
✓ Branch 12 taken 175374 times.
✓ Branch 13 taken 436930 times.
6406142 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3123 763475 || (attackclk<=4))
3124 5969212 return false;
3125
3126 436930 weapon *w=NULL;
3127
3128 436930 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3129 436930 bool found = false;
3130 436930 int32_t melee_weapon_index = 0;
3131 436930 int32_t parentitem=-1;
3132 436930 weapon* meleeweap = nullptr;
3133
2/2
✓ Branch 0 taken 46511 times.
✓ Branch 1 taken 506878 times.
553389 for(int32_t i=0; i<Lwpns.Count(); i++)
3134 {
3135 506878 w = (weapon*)Lwpns.spr(i);
3136
3137
6/6
✓ Branch 0 taken 506840 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 11328 times.
✓ Branch 3 taken 495512 times.
✓ Branch 4 taken 116459 times.
✓ Branch 5 taken 390419 times.
506878 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3138 {
3139 390419 found = true;
3140 390419 melee_weapon_index = i+1;
3141 390419 meleeweap = w;
3142 // Position the sword as Hero slashes with it.
3143
3/4
✓ Branch 0 taken 371389 times.
✓ Branch 1 taken 19030 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 371389 times.
390419 if(w->id!=wHammer&&w->id!=wBugNet)
3144 371389 positionSword(w,w->parentitem);
3145
3146 390419 wx=w->x;
3147 390419 wy=w->y;
3148 390419 wz=w->z;
3149 390419 wxsz = w->hit_width;
3150 390419 wysz = w->hit_height;
3151 390419 parentitem = w->parentitem;
3152 390419 break;
3153 }
3154 116459 }
3155
3156
6/6
✓ Branch 0 taken 393905 times.
✓ Branch 1 taken 43025 times.
✓ Branch 2 taken 40550 times.
✓ Branch 3 taken 353355 times.
✓ Branch 4 taken 1806 times.
✓ Branch 5 taken 38744 times.
436930 if(attack==wSword && attackclk>=14 && charging==0)
3157 38744 return false;
3158
3159
2/2
✓ Branch 0 taken 351675 times.
✓ Branch 1 taken 46511 times.
398186 if(!found)
3160 46511 return false;
3161
3162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 351675 times.
351675 if(attack == wFire)
3163 return false;
3164
3165
2/2
✓ Branch 0 taken 332645 times.
✓ Branch 1 taken 19030 times.
351675 if(attack==wHammer)
3166 {
3167
2/2
✓ Branch 0 taken 7473 times.
✓ Branch 1 taken 11557 times.
19030 if(attackclk<15)
3168 {
3169
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1152 times.
✓ Branch 2 taken 1702 times.
✓ Branch 3 taken 2090 times.
✓ Branch 4 taken 2529 times.
7473 switch(w->dir)
3170 {
3171 case up:
3172 1152 wx=x-1;
3173 1152 wy=y-4;
3174 1152 break;
3175
3176 case down:
3177 1702 wx=x+8;
3178 1702 wy=y+28;
3179 1702 break; // This is consistent with 2.10
3180
3181 case left:
3182 2090 wx=x-13;
3183 2090 wy=y+14;
3184 2090 break;
3185
3186 case right:
3187 2529 wx=x+21;
3188 2529 wy=y+14;
3189 2529 break;
3190 }
3191
3192
6/8
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 6732 times.
✓ Branch 2 taken 741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 741 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 739 times.
7473 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3193 {
3194 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3195 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3196 switch(dir)
3197 {
3198 case up:
3199 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3200 break;
3201
3202 case down:
3203 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3204 break;
3205
3206 case left:
3207 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3208 break;
3209
3210 case right:
3211 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3212 break;
3213 }
3214 */
3215 739 }
3216
3217 7473 return false;
3218 }
3219
2/2
✓ Branch 0 taken 10823 times.
✓ Branch 1 taken 734 times.
11557 else if(attackclk==15)
3220 {
3221 // Hammer's reach needs adjusted slightly for backward compatibility
3222
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 114 times.
734 if(w->dir==up)
3223 114 w->hyofs-=1;
3224
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 207 times.
620 else if(w->dir==left)
3225 207 w->hxofs-=2;
3226 734 }
3227 11557 }
3228
3229 // The return of Spaghetti Code Constants!
3230
6/6
✓ Branch 0 taken 13622 times.
✓ Branch 1 taken 330580 times.
✓ Branch 2 taken 319005 times.
✓ Branch 3 taken 11575 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 11557 times.
344202 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3231
3/4
✓ Branch 0 taken 17374 times.
✓ Branch 1 taken 326828 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17374 times.
344202 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3232 344202 itemid = vbound(itemid, 0, MAXITEMS-1);
3233
3234 // The sword offsets aren't based on anything other than what felt about right
3235 // compared to the NES game and what mostly kept it from hitting things that
3236 // should clearly be out of range. They could probably still use more tweaking.
3237 // Don't use 2.10 for reference; it's pretty far off.
3238 // - Saf
3239
3240
6/6
✓ Branch 0 taken 34517 times.
✓ Branch 1 taken 309685 times.
✓ Branch 2 taken 5420 times.
✓ Branch 3 taken 29097 times.
✓ Branch 4 taken 8227 times.
✓ Branch 5 taken 26290 times.
344202 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3241 {
3242
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 6673 times.
✓ Branch 3 taken 7821 times.
✓ Branch 4 taken 7540 times.
26290 switch(w->dir)
3243 {
3244 case up:
3245
2/2
✓ Branch 0 taken 2745 times.
✓ Branch 1 taken 1511 times.
4256 if(attackclk<8)
3246 {
3247 1511 wy-=4;
3248 1511 }
3249
3250 4256 break;
3251
3252 case down:
3253 //if(attackclk<8)
3254 {
3255 6673 wy-=2;
3256 }
3257 6673 break;
3258
3259 case left:
3260
3261 //if(attackclk<8)
3262 {
3263 7821 wx+=2;
3264 }
3265
3266 7821 break;
3267
3268 case right:
3269
3270 //if(attackclk<8)
3271 {
3272 7540 wx-=3;
3273 //wy+=((spins>0 || get_bit(quest_rules, qr_SLASHFLIPFIX)) ? -4 : 4);
3274 }
3275
3276 7540 break;
3277 }
3278 26290 }
3279
3280
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 77747 times.
✓ Branch 2 taken 75048 times.
✓ Branch 3 taken 94585 times.
✓ Branch 4 taken 96822 times.
344202 switch(w->dir)
3281 {
3282 case up:
3283 77747 wx+=2;
3284 77747 break;
3285
3286 case down:
3287 75048 break;
3288
3289 case left:
3290 94585 wy-=3;
3291 94585 break;
3292
3293 case right:
3294 96822 wy-=3;
3295 96822 break;
3296 }
3297
3298 344202 wx+=w->hxofs;
3299 344202 wy+=w->hyofs;
3300 344202 wy-=(w->fakez).getInt();
3301
3302
2/2
✓ Branch 0 taken 341024 times.
✓ Branch 1 taken 1702666 times.
2043690 for(int32_t i=0; i<guys.Count(); i++)
3303 {
3304
1/2
✓ Branch 0 taken 1702666 times.
✗ Branch 1 not taken.
1702666 if(attack==wBugNet) break;
3305 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3306
6/6
✓ Branch 0 taken 34365 times.
✓ Branch 1 taken 1668301 times.
✓ Branch 2 taken 33886 times.
✓ Branch 3 taken 479 times.
✓ Branch 4 taken 33242 times.
✓ Branch 5 taken 644 times.
1702980 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3307
5/6
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 1125 times.
✓ Branch 2 taken 1570041 times.
✓ Branch 3 taken 98804 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1668355 times.
1669424 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3308
4/4
✓ Branch 0 taken 47794 times.
✓ Branch 1 taken 1620561 times.
✓ Branch 2 taken 314 times.
✓ Branch 3 taken 47480 times.
1668355 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3309 {
3310 // Checking the whimsical ring for every collision check causes
3311 // an odd bug. It's much more likely to activate on a 0-damage
3312 // weapon, since a 0-damage hit won't make the enemy invulnerable
3313 // to damaging hits in the following frames.
3314
3315 34367 int32_t whimsyid = current_item_id(itype_whimsicalring);
3316
3317 34367 int32_t dmg = weaponattackpower(itemid);
3318
2/2
✓ Branch 0 taken 32458 times.
✓ Branch 1 taken 1909 times.
34367 if(whimsyid>-1)
3319 {
3320
3/4
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1793 times.
✓ Branch 3 taken 116 times.
1909 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3321 116 dmg += current_item_power(itype_whimsicalring);
3322 1793 else whimsyid = -1;
3323 1909 }
3324 34367 int32_t atkringid = current_item_id(itype_atkring);
3325
2/2
✓ Branch 0 taken 34359 times.
✓ Branch 1 taken 8 times.
34367 if(atkringid>-1)
3326 {
3327 8 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3328 8 dmg += itemsbuf[atkringid].misc1; //Additive
3329 8 }
3330
3331 34367 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn,w);
3332 34367 enemy *e = (enemy*)guys.spr(i);
3333
2/2
✓ Branch 0 taken 11723 times.
✓ Branch 1 taken 22644 times.
34367 if (h == -1)
3334 {
3335 22644 e->hitby[HIT_BY_LWEAPON] = melee_weapon_index;
3336 22644 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
3337 22644 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
3338
1/2
✓ Branch 0 taken 22644 times.
✗ Branch 1 not taken.
22644 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
3339 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
3340 22644 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
3341 22644 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
3342 22644 } //temp_hit = true; }
3343 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3344
3345
4/4
✓ Branch 0 taken 22644 times.
✓ Branch 1 taken 11723 times.
✓ Branch 2 taken 22599 times.
✓ Branch 3 taken 45 times.
34367 if(h<0 && whimsyid>-1)
3346 {
3347 45 sfx(itemsbuf[whimsyid].usesound);
3348 45 }
3349
3350
4/4
✓ Branch 0 taken 29804 times.
✓ Branch 1 taken 4563 times.
✓ Branch 2 taken 29710 times.
✓ Branch 3 taken 94 times.
34367 if(h && charging>0)
3351 {
3352 94 attackclk = SWORDTAPFRAME;
3353 94 spins=0;
3354 94 }
3355
3356
8/8
✓ Branch 0 taken 29804 times.
✓ Branch 1 taken 4563 times.
✓ Branch 2 taken 25733 times.
✓ Branch 3 taken 4071 times.
✓ Branch 4 taken 25724 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 25716 times.
34367 if(h && hclk==0 && inlikelike != 1 && !get_bit(quest_rules, qr_DYING_ENEMIES_IGNORE_STUN))
3357 {
3358
2/2
✓ Branch 0 taken 25635 times.
✓ Branch 1 taken 81 times.
25716 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3359 {
3360 81 hithero(i);
3361 81 }
3362 25716 }
3363
3364
2/2
✓ Branch 0 taken 31133 times.
✓ Branch 1 taken 3234 times.
34367 if(h==2)
3365 3234 break;
3366 31133 }
3367 1699488 }
3368
3369
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 344128 times.
688460 if(attack == wBugNet
3370
3/4
✓ Branch 0 taken 344202 times.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 344202 times.
344258 || (parentitem==-1&&!get_bit(quest_rules,qr_NOITEMMELEE))
3371
1/2
✓ Branch 0 taken 344202 times.
✗ Branch 1 not taken.
344202 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3372 {
3373
1/4
✓ Branch 0 taken 344184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
344184 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3374
2/2
✓ Branch 0 taken 344184 times.
✓ Branch 1 taken 88470 times.
432654 for(int32_t j=0; j<items.Count(); j++)
3375 {
3376 88470 item* ptr = (item*)items.spr(j);
3377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88470 times.
88470 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3378 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3379
3380
2/4
✓ Branch 0 taken 88470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88470 times.
✗ Branch 3 not taken.
88470 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3381 continue; //No picking these up unless you have a bottle to fill!
3382
5/6
✓ Branch 0 taken 88443 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17604 times.
✓ Branch 3 taken 70839 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17604 times.
88470 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3383 {
3384
7/8
✓ Branch 0 taken 70839 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 30156 times.
✓ Branch 3 taken 40683 times.
✓ Branch 4 taken 40710 times.
✓ Branch 5 taken 30156 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 40710 times.
70866 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3385 {
3386
6/6
✓ Branch 0 taken 38341 times.
✓ Branch 1 taken 2369 times.
✓ Branch 2 taken 961 times.
✓ Branch 3 taken 37380 times.
✓ Branch 4 taken 38332 times.
✓ Branch 5 taken 2378 times.
79050 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3387
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 37617 times.
✓ Branch 3 taken 723 times.
38341 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3388 {
3389 2378 int32_t pickup = ptr->pickup;
3390 2378 int32_t id2 = ptr->id;
3391 2378 int32_t pstr = ptr->pstring;
3392 2378 int32_t pstr_flags = ptr->pickup_string_flags;
3393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(!dofairy)
3394 {
3395 2378 std::vector<int32_t> &ev = FFCore.eventData;
3396 2378 ev.clear();
3397 2378 ev.push_back(id2*10000);
3398 2378 ev.push_back(pickup*10000);
3399 2378 ev.push_back(pstr*10000);
3400 2378 ev.push_back(pstr_flags*10000);
3401 2378 ev.push_back(0);
3402 2378 ev.push_back(ptr->getUID());
3403 2378 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3404 2378 ev.push_back(w->getUID());
3405
3406 2378 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3407 2378 bool nullify = ev[4] != 0;
3408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(nullify) continue;
3409 2378 id2 = ev[0]/10000;
3410 2378 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3411 2378 pstr = ev[2] / 10000;
3412 2378 pstr_flags = ev[3] / 10000;
3413 2378 }
3414
3415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(pickup&ipONETIME) // set mITEM for one-time-only items
3416 setmapflag(mITEM);
3417
1/2
✓ Branch 0 taken 2378 times.
✗ Branch 1 not taken.
2378 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3418 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3419
3420
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2378 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3421 setxmapflag(1<<ptr->pickupexstate);
3422
1/2
✓ Branch 0 taken 2378 times.
✗ Branch 1 not taken.
2378 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3423 {
3424 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3425 hidden_entrance(0, true, false, -5);
3426 }
3427 //!DIMI
3428
3429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(dofairy)
3430 {
3431 game->fillBottle(itemsbuf[ptr->id].misc4);
3432 }
3433 else
3434 {
3435 2378 collectitem_script(id2);
3436
3437 2378 getitem(id2, false, true);
3438 }
3439 2378 items.del(j);
3440
3441
2/2
✓ Branch 0 taken 2947 times.
✓ Branch 1 taken 2378 times.
5325 for(int32_t i=0; i<Lwpns.Count(); i++)
3442 {
3443 2947 weapon *w2 = (weapon*)Lwpns.spr(i);
3444
3445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2947 times.
2947 if(w2->dragging==j)
3446 {
3447 w2->dragging=-1;
3448 }
3449
1/2
✓ Branch 0 taken 2947 times.
✗ Branch 1 not taken.
2947 else if(w2->dragging>j)
3450 {
3451 w2->dragging-=1;
3452 }
3453 2947 }
3454
3455
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2378 if ( (pstr > 0 && pstr < msg_count) )
3456 {
3457 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3458 {
3459 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3460 FFCore.SetItemMessagePlayed(id2);
3461 donewmsg(pstr);
3462 break;
3463 }
3464 }
3465
3466 2378 --j;
3467 2378 }
3468 40710 }
3469 70866 }
3470 88470 }
3471 344184 }
3472
3473
3/4
✓ Branch 0 taken 344184 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 344184 times.
344258 if(attack==wCByrna || attack==wBugNet)
3474 74 return false;
3475
3476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344184 times.
344184 if(meleeweap->no_triggers())
3477 return false;
3478
3479
2/2
✓ Branch 0 taken 319005 times.
✓ Branch 1 taken 25179 times.
344184 if(attack==wSword)
3480 {
3481
2/2
✓ Branch 0 taken 279258 times.
✓ Branch 1 taken 39747 times.
319005 if(attackclk == 6)
3482 {
3483
2/2
✓ Branch 0 taken 6995472 times.
✓ Branch 1 taken 39747 times.
7035219 for(int32_t q=0; q<176; q++)
3484 {
3485 6995472 set_bit(screengrid,q,0);
3486 6995472 set_bit(screengrid_layer[0],q,0);
3487 6995472 set_bit(screengrid_layer[1],q,0);
3488 6995472 }
3489
3490
2/2
✓ Branch 0 taken 635952 times.
✓ Branch 1 taken 39747 times.
675699 for(dword q = MAXFFCS/8; q > 0; --q)
3491 635952 ffcgrid[q-1] = 0;
3492 39747 }
3493
3494
4/4
✓ Branch 0 taken 73314 times.
✓ Branch 1 taken 245691 times.
✓ Branch 2 taken 37264 times.
✓ Branch 3 taken 36050 times.
319005 if(dir==up && ((x.getInt()&15)==0))
3495 {
3496 36050 check_slash_block(wx,wy);
3497 36050 check_slash_block(wx,wy+8);
3498
3499 //layers
3500 36050 check_slash_block_layer(wx,wy,1);
3501 36050 check_slash_block_layer(wx,wy+8,1);
3502 36050 check_slash_block_layer(wx,wy,1);
3503 36050 check_slash_block_layer(wx,wy+8,1);
3504 //2
3505 36050 check_slash_block_layer(wx,wy,2);
3506 36050 check_slash_block_layer(wx,wy+8,2);
3507 36050 check_slash_block_layer(wx,wy,2);
3508 36050 check_slash_block_layer(wx,wy+8,2);
3509 36050 }
3510
8/10
✓ Branch 0 taken 37264 times.
✓ Branch 1 taken 245691 times.
✓ Branch 2 taken 1957 times.
✓ Branch 3 taken 35307 times.
✓ Branch 4 taken 155 times.
✓ Branch 5 taken 1802 times.
✓ Branch 6 taken 155 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 155 times.
282955 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3511 {
3512 37109 check_slash_block(wx,wy);
3513 37109 check_slash_block(wx,wy+8);
3514 37109 check_slash_block(wx+8,wy);
3515 37109 check_slash_block(wx+8,wy+8);
3516 ///layer 1
3517 37109 check_slash_block_layer(wx,wy,1);
3518 37109 check_slash_block_layer(wx,wy+8,1);
3519 37109 check_slash_block_layer(wx+8,wy,1);
3520 37109 check_slash_block_layer(wx+8,wy+8,1);
3521 ///layer 2
3522 37109 check_slash_block_layer(wx,wy,2);
3523 37109 check_slash_block_layer(wx,wy+8,2);
3524 37109 check_slash_block_layer(wx+8,wy,2);
3525 37109 check_slash_block_layer(wx+8,wy+8,2);
3526 37109 }
3527
4/4
✓ Branch 0 taken 70560 times.
✓ Branch 1 taken 248445 times.
✓ Branch 2 taken 34004 times.
✓ Branch 3 taken 36556 times.
319005 if(dir==down && ((x.getInt()&15)==0))
3528 {
3529 36556 check_slash_block(wx,wy+wysz-8);
3530 36556 check_slash_block(wx,wy+wysz);
3531
3532 //layer 1
3533 36556 check_slash_block_layer(wx,wy+wysz-8,1);
3534 36556 check_slash_block_layer(wx,wy+wysz,1);
3535 //layer 2
3536 36556 check_slash_block_layer(wx,wy+wysz-8,2);
3537 36556 check_slash_block_layer(wx,wy+wysz,2);
3538 36556 }
3539
8/10
✓ Branch 0 taken 34004 times.
✓ Branch 1 taken 248445 times.
✓ Branch 2 taken 3477 times.
✓ Branch 3 taken 30527 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 3397 times.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 80 times.
282449 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3540 {
3541 33924 check_slash_block(wx,wy+wysz-8);
3542 33924 check_slash_block(wx,wy+wysz);
3543 33924 check_slash_block(wx+8,wy+wysz-8);
3544 33924 check_slash_block(wx+8,wy+wysz);
3545 //layer 1
3546 33924 check_slash_block_layer(wx,wy+wysz-8,1);
3547 33924 check_slash_block_layer(wx,wy+wysz,1);
3548 33924 check_slash_block_layer(wx+8,wy+wysz-8,1);
3549 33924 check_slash_block_layer(wx+8,wy+wysz,1);
3550 //layer 2
3551 33924 check_slash_block_layer(wx,wy+wysz-8,2);
3552 33924 check_slash_block_layer(wx,wy+wysz,2);
3553 33924 check_slash_block_layer(wx+8,wy+wysz-8,2);
3554 33924 check_slash_block_layer(wx+8,wy+wysz,2);
3555 33924 }
3556
3557
2/2
✓ Branch 0 taken 232809 times.
✓ Branch 1 taken 86196 times.
319005 if(dir==left)
3558 {
3559 86196 check_slash_block(wx,wy+8);
3560 86196 check_slash_block(wx+8,wy+8);
3561 //layer 1
3562 86196 check_slash_block_layer(wx,wy+8,1);
3563 86196 check_slash_block_layer(wx+8,wy+8,1);
3564 //layer 2
3565 86196 check_slash_block_layer(wx,wy+8,2);
3566 86196 check_slash_block_layer(wx+8,wy+8,2);
3567 86196 }
3568
3569
2/2
✓ Branch 0 taken 230070 times.
✓ Branch 1 taken 88935 times.
319005 if(dir==right)
3570 {
3571 88935 check_slash_block(wx+wxsz,wy+8);
3572 88935 check_slash_block(wx+wxsz-8,wy+8);
3573 //layer 1
3574 88935 check_slash_block_layer(wx+wxsz,wy+8,1);
3575 88935 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3576 //layer 2
3577 88935 check_slash_block_layer(wx+wxsz,wy+8,2);
3578 88935 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3579 88935 }
3580 319005 }
3581
2/2
✓ Branch 0 taken 13622 times.
✓ Branch 1 taken 11557 times.
25179 else if(attack==wWand)
3582 {
3583
1/2
✓ Branch 0 taken 13622 times.
✗ Branch 1 not taken.
13622 if(attackclk == 5)
3584 {
3585 for(int32_t q=0; q<176; q++)
3586 {
3587 set_bit(screengrid,q,0);
3588 set_bit(screengrid_layer[0],q,0);
3589 set_bit(screengrid_layer[1],q,0);
3590 }
3591
3592 for(dword q = MAXFFCS/8; q > 0; --q)
3593 ffcgrid[q-1] = 0;
3594 }
3595
3596 // cutable blocks
3597
4/4
✓ Branch 0 taken 2662 times.
✓ Branch 1 taken 10960 times.
✓ Branch 2 taken 1464 times.
✓ Branch 3 taken 1198 times.
13622 if(dir==up && (x.getInt()&15)==0)
3598 {
3599 1198 check_wand_block(wx,wy);
3600 1198 check_wand_block(wx,wy+8);
3601 1198 }
3602
5/10
✓ Branch 0 taken 1464 times.
✓ Branch 1 taken 10960 times.
✓ Branch 2 taken 630 times.
✓ Branch 3 taken 834 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 630 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
12424 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3603 {
3604 1464 check_wand_block(wx,wy);
3605 1464 check_wand_block(wx,wy+8);
3606 1464 check_wand_block(wx+8,wy);
3607 1464 check_wand_block(wx+8,wy+8);
3608 1464 }
3609
3610
4/4
✓ Branch 0 taken 1876 times.
✓ Branch 1 taken 11746 times.
✓ Branch 2 taken 824 times.
✓ Branch 3 taken 1052 times.
13622 if(dir==down && (x.getInt()&15)==0)
3611 {
3612 1052 check_wand_block(wx,wy+wysz-8);
3613 1052 check_wand_block(wx,wy+wysz);
3614 1052 }
3615
5/10
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 11746 times.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 689 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 135 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
12570 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3616 {
3617 824 check_wand_block(wx,wy+wysz-8);
3618 824 check_wand_block(wx,wy+wysz);
3619 824 check_wand_block(wx+8,wy+wysz-8);
3620 824 check_wand_block(wx+8,wy+wysz);
3621 824 }
3622
3623
2/2
✓ Branch 0 taken 8509 times.
✓ Branch 1 taken 5113 times.
13622 if(dir==left)
3624 {
3625 5113 check_wand_block(wx,y+8);
3626 5113 check_wand_block(wx+8,y+8);
3627 5113 }
3628
3629
2/2
✓ Branch 0 taken 9651 times.
✓ Branch 1 taken 3971 times.
13622 if(dir==right)
3630 {
3631 3971 check_wand_block(wx+wxsz,y+8);
3632 3971 check_wand_block(wx+wxsz-8,y+8);
3633 3971 }
3634 13622 }
3635
4/8
✓ Branch 0 taken 11557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10823 times.
✓ Branch 3 taken 734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10823 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11557 else if((attack==wHammer) && ((attackclk==15) || ( spins>0 && attackclk >=15 )))
3636 {
3637 // poundable blocks
3638
2/2
✓ Branch 0 taken 129184 times.
✓ Branch 1 taken 734 times.
129918 for(int32_t q=0; q<176; q++)
3639 {
3640 129184 set_bit(screengrid,q,0);
3641 129184 set_bit(screengrid_layer[0],q,0);
3642 129184 set_bit(screengrid_layer[1],q,0);
3643 129184 }
3644
3645
2/2
✓ Branch 0 taken 11744 times.
✓ Branch 1 taken 734 times.
12478 for(dword q = MAXFFCS/8; q > 0; --q)
3646 11744 ffcgrid[q-1] = 0;
3647
3648
4/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 63 times.
734 if(dir==up && (x.getInt()&15)==0)
3649 {
3650 63 check_pound_block(wx,wy);
3651 63 check_pound_block(wx,wy+8);
3652 63 }
3653
3/10
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 618 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
671 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3654 {
3655 53 check_pound_block(wx,wy);
3656 53 check_pound_block(wx,wy+8);
3657 53 check_pound_block(wx+8,wy);
3658 53 check_pound_block(wx+8,wy+8);
3659 53 }
3660
3661
4/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 574 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 95 times.
734 if(dir==down && (x.getInt()&15)==0)
3662 {
3663 95 check_pound_block(wx,wy+wysz-8);
3664 95 check_pound_block(wx,wy+wysz);
3665 95 }
3666
5/10
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 574 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
639 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3667 {
3668 65 check_pound_block(wx,wy+wysz-8);
3669 65 check_pound_block(wx,wy+wysz);
3670 65 check_pound_block(wx+8,wy+wysz-8);
3671 65 check_pound_block(wx+8,wy+wysz);
3672 65 }
3673
3674
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 212 times.
734 if(dir==left)
3675 {
3676 212 check_pound_block(wx,y+8);
3677 212 check_pound_block(wx+8,y+8);
3678 212 }
3679
3680
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 246 times.
734 if(dir==right)
3681 {
3682 246 check_pound_block(wx+wxsz,y+8);
3683 246 check_pound_block(wx+wxsz-8,y+8);
3684 246 }
3685 734 }
3686 10823 else return false;
3687
3688 333361 return true;
3689 6406198 }
3690
3691 1703412 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3692 {
3693
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 1701720 times.
1703412 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
3694 {
3695 //zprint("bit off\n");
3696 1701720 return;
3697 }
3698 //keep things inside the screen boundaries
3699 1692 bx=vbound(bx, 0, 255);
3700 1692 by=vbound(by, 0, 176);
3701 1692 int32_t fx=vbound(bx, 0, 255);
3702 1692 int32_t fy=vbound(by, 0, 176);
3703 //first things first
3704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(attack!=wSword)
3705 return;
3706
3707
3/6
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1692 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 176 times.
1868 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3708
3/4
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 176 times.
✓ Branch 3 taken 1516 times.
1692 || (attackclk>SWORDTAPFRAME && tapping))
3709 return;
3710
3711 //find out which combo row/column the coordinates are in
3712 1692 bx &= 0xF0;
3713 1692 by &= 0xF0;
3714
3715
3716 1692 int32_t flag = MAPFLAGL(layer,bx,by);
3717 1692 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3718 1692 int32_t cid = MAPCOMBOL(layer,bx,by);
3719 1692 int32_t type = combobuf[cid].type;
3720
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3721 type = cNONE;
3722 //zprint("cid is: %d\n", cid);
3723 //zprint("type is: %d\n", type);
3724 1692 int32_t i = (bx>>4) + by;
3725
3726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(i > 175)
3727 return;
3728
3729 1692 bool ignorescreen=false;
3730
3731
2/4
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1692 times.
✗ Branch 3 not taken.
1692 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3732 1692 return;
3733
3734 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3735
3736 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3737 if(isCuttableNextType(type))
3738 {
3739 FFCore.tempScreens[layer]->data[i]++;
3740 }
3741 else
3742 {
3743 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3744 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3745 FFCore.tempScreens[layer]->sflag[i] = 0;
3746 }
3747 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3748 {
3749 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3750 sfx(tmpscr->secretsfx);
3751 }
3752 else if(isCuttableItemType(type))
3753 {
3754 int32_t it = -1;
3755 int32_t thedropset = -1;
3756
3757 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3758 if ( (combobuf[cid].usrflags&cflag2) )
3759 {
3760 if(combobuf[cid].usrflags&cflag11)
3761 it = combobuf[cid].attribytes[1];
3762 else
3763 {
3764 it = select_dropitem(combobuf[cid].attribytes[1]);
3765 thedropset = combobuf[cid].attribytes[1];
3766 }
3767 }
3768 else
3769 {
3770 it = select_dropitem(12);
3771 thedropset = 12;
3772 }
3773 if(it!=-1)
3774 {
3775 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3776 itm->from_dropset = thedropset;
3777 items.add(itm);
3778 }
3779 }
3780
3781 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3782
3783 if(get_bit(quest_rules,qr_MORESOUNDS))
3784 {
3785 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3786 {
3787 if (combobuf[cid].usrflags&cflag3)
3788 {
3789 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3790 }
3791 }
3792 else
3793 {
3794 if (combobuf[cid].usrflags&cflag3)
3795 {
3796 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3797 }
3798 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3799 }
3800 }
3801
3802 spawn_decoration_xy(combobuf[cid], fx, fy);
3803 1703412 }
3804
3805 779606 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3806 {
3807 //keep things inside the screen boundaries
3808 779606 bx=vbound(bx, 0, 255);
3809 779606 by=vbound(by, 0, 176);
3810 779606 int32_t fx=vbound(bx, 0, 255);
3811 779606 int32_t fy=vbound(by, 0, 176);
3812 //first things first
3813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779606 times.
779606 if(attack!=wSword)
3814 return;
3815
3816
4/6
✓ Branch 0 taken 779606 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 779606 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 93808 times.
873666 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3817
4/4
✓ Branch 0 taken 775744 times.
✓ Branch 1 taken 3862 times.
✓ Branch 2 taken 94060 times.
✓ Branch 3 taken 681684 times.
779606 || (attackclk>SWORDTAPFRAME && tapping))
3818 4114 return;
3819
3820 //find out which combo row/column the coordinates are in
3821 775492 bx &= 0xF0;
3822 775492 by &= 0xF0;
3823
3824 775492 int cid = MAPCOMBO(bx,by);
3825 775492 int cid_ff = MAPFFCOMBO(fx,fy);
3826 775492 int current_ffcombo = getFFCAt(fx,fy);
3827 775492 newcombo const& cmb = combobuf[cid];
3828 775492 newcombo const& cmb_ff = combobuf[cid_ff];
3829 775492 int type = cmb.type;
3830 775492 int type2 = cmb_ff.type;
3831 775492 int flag = MAPFLAG(bx,by);
3832 775492 int flag2 = cmb.flag;
3833 775492 int flag3 = cmb_ff.flag;
3834 775492 int i = (bx>>4) + by;
3835
3836
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 775471 times.
775492 if(i > 175)
3837 21 return;
3838
3839 775471 bool ignorescreen=false;
3840 775471 bool ignoreffc=false;
3841
3842
2/2
✓ Branch 0 taken 767260 times.
✓ Branch 1 taken 8211 times.
775471 if(get_bit(screengrid, i) != 0)
3843 {
3844 8211 ignorescreen = true;
3845 8211 }
3846
2/2
✓ Branch 0 taken 767255 times.
✓ Branch 1 taken 5 times.
767260 else if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
3847 5 ignorescreen = true;
3848
3849
3850
3851
3/4
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 771762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3709 times.
775471 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
3852 {
3853 771762 ignoreffc = true;
3854 771762 }
3855
2/2
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 19 times.
3709 else if(cmb_ff.triggerflags[0] & combotriggerONLYGENTRIG)
3856 19 ignoreffc = true;
3857
3858
3/4
✓ Branch 0 taken 771812 times.
✓ Branch 1 taken 3659 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 771767 times.
1547238 if(!isCuttableType(type) &&
3859
6/6
✓ Branch 0 taken 1213 times.
✓ Branch 1 taken 770599 times.
✓ Branch 2 taken 771767 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 771722 times.
771812 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
3860 {
3861 771767 ignorescreen = true;
3862 771767 }
3863
3864
3/4
✓ Branch 0 taken 775452 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 775452 times.
1550923 if(!isCuttableType(type2) &&
3865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 775452 times.
775452 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
3866 {
3867 775452 ignoreffc = true;
3868 775452 }
3869
3870 775471 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
3871
3872
3/4
✓ Branch 0 taken 32952 times.
✓ Branch 1 taken 742519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32952 times.
775471 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3873 775471 byte skipsecrets = 0;
3874
3875
2/2
✓ Branch 0 taken 772961 times.
✓ Branch 1 taken 2510 times.
775471 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
3876 {
3877
2/2
✓ Branch 0 taken 2466 times.
✓ Branch 1 taken 44 times.
2510 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
3878 {
3879 2466 skipsecrets = 0;
3880 2466 }
3881 44 else skipsecrets = 1; ;
3882 2510 }
3883
3884
6/6
✓ Branch 0 taken 2156 times.
✓ Branch 1 taken 773315 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 2117 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 51 times.
775471 if(!ignorescreen && (!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
3885 {
3886
5/6
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2103 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
2168 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
3887 {
3888 13 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3889 13 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3890 13 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3891 13 }
3892
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2151 times.
2155 else if(flag == mfARMOS_SECRET)
3893 {
3894 4 s->data[i] = s->secretcombo[sSTAIRS];
3895 4 s->cset[i] = s->secretcset[sSTAIRS];
3896 4 s->sflag[i] = s->secretflag[sSTAIRS];
3897 4 sfx(tmpscr->secretsfx);
3898 4 }
3899
4/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 2100 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 2094 times.
2151 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
3900 {
3901
4/4
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 45 times.
164 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3902 {
3903 107 findentrance(bx,by,mfSWORD+i2,true);
3904 107 }
3905
3906 45 findentrance(bx,by,mfSTRIKE,true);
3907 45 }
3908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2094 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2094 else if(((flag2 >= 16)&&(flag2 <= 31)))
3909 {
3910 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3911 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3912 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3913 }
3914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2094 times.
2094 else if(flag2 == mfARMOS_SECRET)
3915 {
3916 s->data[i] = s->secretcombo[sSTAIRS];
3917 s->cset[i] = s->secretcset[sSTAIRS];
3918 s->sflag[i] = s->secretflag[sSTAIRS];
3919 sfx(tmpscr->secretsfx);
3920 }
3921
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2094 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2094 times.
2094 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
3922 {
3923 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3924 {
3925 findentrance(bx,by,mfSWORD+i2,true);
3926 }
3927
3928 findentrance(bx,by,mfSTRIKE,true);
3929 }
3930 else
3931 {
3932
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 1134 times.
2094 if(isCuttableNextType(type))
3933 {
3934 960 s->data[i]++;
3935 960 }
3936 else
3937 {
3938 1134 s->data[i] = s->undercombo;
3939 1134 s->cset[i] = s->undercset;
3940 1134 s->sflag[i] = 0;
3941 }
3942
3943 //pausenow=true;
3944 }
3945 2156 }
3946
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 773327 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
773327 else if(!ignorescreen && skipsecrets)
3947 {
3948 if(isCuttableNextType(type))
3949 {
3950 s->data[i]++;
3951 }
3952 else
3953 {
3954 s->data[i] = s->undercombo;
3955 s->cset[i] = s->undercset;
3956 s->sflag[i] = 0;
3957 }
3958 }
3959
3960
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 775483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 775483 times.
775483 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
3961 {
3962 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3963 {
3964 findentrance(bx,by,mfSWORD+i2,true);
3965 }
3966
3967 findentrance(fx,fy,mfSTRIKE,true);
3968 }
3969
1/2
✓ Branch 0 taken 775483 times.
✗ Branch 1 not taken.
775483 else if(!ignoreffc)
3970 {
3971 if(isCuttableNextType(type2))
3972 {
3973 s->ffcs[current_ffcombo].incData(1);
3974 }
3975 else
3976 {
3977 s->ffcs[current_ffcombo].setData(s->undercombo);
3978 s->ffcs[current_ffcombo].cset = s->undercset;
3979 }
3980 }
3981
3982
2/2
✓ Branch 0 taken 773327 times.
✓ Branch 1 taken 2156 times.
775483 if(!ignorescreen)
3983 {
3984
4/4
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 1172 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 955 times.
2156 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
3985
3986
8/8
✓ Branch 0 taken 2133 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2134 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 21 times.
2156 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3987 {
3988
4/8
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
22 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3989 22 sfx(tmpscr->secretsfx);
3990 22 }
3991
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 2086 times.
2134 else if(isCuttableItemType(type))
3992 {
3993 2086 int32_t it = -1;
3994 2086 int32_t thedropset = -1;
3995
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2064 times.
2086 if ( (cmb.usrflags&cflag2) ) //specific dropset or item
3996 {
3997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if ( cmb.usrflags&cflag11 )
3998 {
3999 it = cmb.attribytes[1];
4000 }
4001 else
4002 {
4003 22 it = select_dropitem(cmb.attribytes[1]);
4004 22 thedropset = cmb.attribytes[1];
4005 }
4006 22 }
4007 else
4008 {
4009 2064 it = select_dropitem(12);
4010 2064 thedropset = 12;
4011 }
4012
4013
2/2
✓ Branch 0 taken 1459 times.
✓ Branch 1 taken 627 times.
2086 if(it!=-1)
4014 {
4015
4/8
✓ Branch 0 taken 627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 627 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 627 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 627 times.
✗ Branch 7 not taken.
627 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4016 627 itm->from_dropset = thedropset;
4017 627 items.add(itm);
4018 627 }
4019 2086 }
4020
4021 2156 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4022
4023
2/2
✓ Branch 0 taken 1963 times.
✓ Branch 1 taken 193 times.
2156 if(get_bit(quest_rules,qr_MORESOUNDS))
4024 {
4025
6/6
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 44 times.
193 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4026 {
4027
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 22 times.
44 if (cmb.usrflags&cflag3)
4028 {
4029 22 sfx(cmb.attribytes[2],int32_t(bx));
4030 22 }
4031 44 }
4032 else
4033 {
4034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (cmb.usrflags&cflag3)
4035 {
4036 sfx(cmb.attribytes[2],int32_t(bx));
4037 }
4038 149 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4039 }
4040 193 }
4041
4042 2156 spawn_decoration_xy(cmb, fx, fy);
4043 2156 }
4044
4045
1/2
✓ Branch 0 taken 775483 times.
✗ Branch 1 not taken.
775483 if(!ignoreffc)
4046 {
4047 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4048
4049 if(isCuttableItemType(type2))
4050 {
4051 int32_t it=-1;
4052 int32_t thedropset=-1;
4053 if ( (cmb_ff.usrflags&cflag2) )
4054 {
4055 if(cmb_ff.usrflags&cflag11)
4056 it = cmb_ff.attribytes[1];
4057 else
4058 {
4059 it = select_dropitem(cmb_ff.attribytes[1]);
4060 thedropset = cmb_ff.attribytes[1];
4061 }
4062 }
4063 else
4064 {
4065 if(get_bit(quest_rules,qr_HARDCODED_FFC_BUSH_DROPS))
4066 {
4067 int32_t r=zc_oldrand()%100;
4068
4069 if(r<15)
4070 it=iHeart; // 15%
4071 else if(r<35)
4072 it=iRupy; // 20%
4073 }
4074 else
4075 {
4076 it = select_dropitem(12);
4077 thedropset = 12;
4078 }
4079 }
4080
4081 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4082 {
4083 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4084 itm->from_dropset = thedropset;
4085 items.add(itm);
4086 }
4087 }
4088
4089 if(get_bit(quest_rules,qr_MORESOUNDS))
4090 {
4091 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4092 {
4093 if (cmb_ff.usrflags&cflag3)
4094 {
4095 sfx(cmb_ff.attribytes[2],int32_t(bx));
4096 }
4097 }
4098 else
4099 {
4100 if (cmb_ff.usrflags&cflag3)
4101 {
4102 sfx(cmb_ff.attribytes[2],int32_t(bx));
4103 }
4104 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4105 }
4106 }
4107
4108 spawn_decoration_xy(cmb_ff, fx, fy);
4109 }
4110 779618 }
4111
4112 13020876 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4113 {
4114 /*
4115 int32_t par_item = w->parentitem;
4116 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4117 int32_t usewpn = -1;
4118 if ( par_item > -1 )
4119 {
4120 usewpn = itemsbuf[par_item].useweapon;
4121 }
4122 else if ( par_item == -1 && w->ScriptGenerated )
4123 {
4124 usewpn = w->useweapon;
4125 }
4126 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4127
4128 */
4129 13020876 bx=vbound(bx, 0, 255);
4130 13020876 by=vbound(by, 0, 176);
4131 13020876 int32_t cid = MAPCOMBO(bx,by);
4132
3/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 201168 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 12818460 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1248 times.
✗ Branch 29 not taken.
13020876 switch(w->useweapon)
4133 {
4134 case wArrow:
4135 findentrance(bx,by,mfARROW,true);
4136 findentrance(bx,by,mfSARROW,true);
4137 findentrance(bx,by,mfGARROW,true);
4138 break;
4139 case wBeam:
4140 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4141 break;
4142 case wHookshot:
4143 findentrance(bx,by,mfHOOKSHOT,true);
4144 break;
4145 case wBrang:
4146 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4147 break;
4148 case wMagic:
4149 findentrance(bx,by,mfWANDMAGIC,true);
4150 break;
4151 case wRefMagic:
4152 findentrance(bx,by,mfWANDMAGIC,true);
4153 break;
4154 case wRefBeam:
4155 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4156 break;
4157 //reflected magic needs to happen in mirrors:
4158 //
4159 //findentrance(bx,by,mfREFMAGIC,true)
4160 case wRefFireball:
4161 findentrance(bx,by,mfREFFIREBALL,true);
4162 break;
4163 case wBomb:
4164 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4165 break;
4166
4167 case wSBomb:
4168 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4169 break;
4170
4171 case wFire:
4172 201168 findentrance(bx,by,mfANYFIRE,true);
4173 201168 findentrance(bx,by,mfSTRONGFIRE,true);
4174 201168 findentrance(bx,by,mfMAGICFIRE,true);
4175 /* if we want the weapon to die
4176 if (findentrance(bx,by,mfANYFIRE,true) ) dead = 1;
4177 if (findentrance(bx,by,mfSTRONGFIRE,true) ) dead = 1;
4178 if (findentrance(bx,by,mfMAGICFIRE,true)) dead = 1;
4179 */
4180 201168 break;
4181
4182 case wScript1:
4183 break;
4184 case wScript2:
4185 break;
4186 case wScript3:
4187 break;
4188 case wScript4:
4189 break;
4190 case wScript5:
4191 break;
4192 case wScript6:
4193 break;
4194 case wScript7:
4195 break;
4196 case wScript8:
4197 break;
4198 case wScript9:
4199 break;
4200 case wScript10:
4201 break;
4202 case wIce:
4203 break;
4204 case wCByrna:
4205 break;
4206 case wWhistle:
4207 break;
4208 case wSSparkle:
4209 case wFSparkle:
4210 break;
4211 case wWind:
4212 break;
4213 case wBait:
4214 break;
4215 case wFlame:
4216 case wThrown:
4217 case wBombos:
4218 case wEther:
4219 case wQuake:
4220 case wSwordLA:
4221 case wSword180:
4222 case wStomp:
4223 break;
4224 case wSword:
4225 case wWand:
4226 //case wCandle:
4227 case wHSHandle:
4228 case wLitBomb:
4229 case wLitSBomb:
4230 1248 break;
4231 12818460 default: break;
4232
4233 }
4234 13020876 }
4235
4236 26041752 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4237 {
4238
4239
2/2
✓ Branch 0 taken 98990 times.
✓ Branch 1 taken 25942762 times.
26041752 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
4240 {
4241 //zprint("bit off\n");
4242 25942762 return;
4243 }
4244 //keep things inside the screen boundaries
4245 98990 bx=vbound(bx, 0, 255);
4246 98990 by=vbound(by, 0, 176);
4247 98990 int32_t fx=vbound(bx, 0, 255);
4248 98990 int32_t fy=vbound(by, 0, 176);
4249 //first things first
4250
1/2
✓ Branch 0 taken 98990 times.
✗ Branch 1 not taken.
98990 if(w->useweapon != wSword)
4251 98990 return;
4252
4253 //find out which combo row/column the coordinates are in
4254 bx &= 0xF0;
4255 by &= 0xF0;
4256
4257
4258 int32_t flag = MAPFLAGL(layer,bx,by);
4259 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4260 int32_t cid = MAPCOMBOL(layer,bx,by);
4261 int32_t type = combobuf[cid].type;
4262 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4263 type = cNONE;
4264 //zprint("cid is: %d\n", cid);
4265 //zprint("type is: %d\n", type);
4266 int32_t i = (bx>>4) + by;
4267
4268 if(i > 175)
4269 return;
4270
4271 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4272 {
4273 return;
4274 //ignorescreen = true;
4275 //zprint("ignoring\n");
4276 }
4277
4278 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4279
4280 {
4281 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4282 if(isCuttableNextType(type) || isCuttableNextType(type))
4283 {
4284 FFCore.tempScreens[layer]->data[i]++;
4285 }
4286 else
4287 {
4288 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4289 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4290 FFCore.tempScreens[layer]->sflag[i] = 0;
4291 }
4292 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4293 {
4294 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4295 sfx(tmpscr->secretsfx);
4296 }
4297 else if(isCuttableItemType(type))
4298 {
4299 int32_t it = -1;
4300 int32_t thedropset = -1;
4301
4302 if ( (combobuf[cid].usrflags&cflag2) )
4303 {
4304 if(combobuf[cid].usrflags&cflag11)
4305 it = combobuf[cid].attribytes[1];
4306 else
4307 {
4308 it = select_dropitem(combobuf[cid].attribytes[1]);
4309 thedropset = combobuf[cid].attribytes[1];
4310 }
4311 }
4312 else
4313 {
4314 it = select_dropitem(12);
4315 thedropset = 12;
4316 }
4317
4318 if(it!=-1)
4319 {
4320 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4321 itm->from_dropset = thedropset;
4322 items.add(itm);
4323 }
4324 }
4325
4326 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4327
4328 if(get_bit(quest_rules,qr_MORESOUNDS))
4329 {
4330 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4331 {
4332 if (combobuf[cid].usrflags&cflag3)
4333 {
4334 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4335 }
4336 }
4337 else
4338 {
4339 if (combobuf[cid].usrflags&cflag3)
4340 {
4341 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4342 }
4343 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4344 }
4345 }
4346
4347 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4348 if(decotype > 3) decotype = 0;
4349 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4350 switch(decotype)
4351 {
4352 case -2: break; //nothing
4353 case -1:
4354 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4355 break;
4356 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4357 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4358 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4359 }
4360
4361 }
4362
4363 26041752 }
4364
4365 13020876 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4366 {
4367 /*
4368 int32_t par_item = w->parentitem;
4369 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4370 int32_t usewpn = -1;
4371 if ( par_item > -1 )
4372 {
4373 usewpn = itemsbuf[par_item].useweapon;
4374 }
4375 else if ( par_item == -1 && w->ScriptGenerated )
4376 {
4377 usewpn = w->useweapon;
4378 }
4379 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4380 */
4381
4382
4383 //keep things inside the screen boundaries
4384 13020876 bx=vbound(bx, 0, 255);
4385 13020876 by=vbound(by, 0, 176);
4386 13020876 int32_t fx=vbound(bx, 0, 255);
4387 13020876 int32_t fy=vbound(by, 0, 176);
4388 13020876 int32_t cid = MAPCOMBO(bx,by);
4389
4390 //find out which combo row/column the coordinates are in
4391 13020876 bx &= 0xF0;
4392 13020876 by &= 0xF0;
4393
4394 13020876 int32_t type = COMBOTYPE(bx,by);
4395 13020876 int32_t type2 = FFCOMBOTYPE(fx,fy);
4396 13020876 int32_t flag = MAPFLAG(bx,by);
4397 13020876 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4398 13020876 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4399
2/2
✓ Branch 0 taken 13020662 times.
✓ Branch 1 taken 214 times.
13020876 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4400 214 type = cNONE;
4401 13020876 byte dontignore = 0;
4402 13020876 byte dontignoreffc = 0;
4403
4404
4/4
✓ Branch 0 taken 217836 times.
✓ Branch 1 taken 12803040 times.
✓ Branch 2 taken 217537 times.
✓ Branch 3 taken 299 times.
13020876 if (isCuttableType(type) && MatchComboTrigger(w, combobuf.data(), cid))
4405 {
4406 299 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4407 299 dontignore = 1;
4408 299 }
4409
4410 /*to-do, ffcs
4411 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4412 {
4413 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4414 dontignoreffc = 1;
4415 }*/
4416
4/4
✓ Branch 0 taken 13019628 times.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 13019329 times.
✓ Branch 3 taken 299 times.
13020876 if(w->useweapon != wSword && !dontignore) return;
4417
4418
4419 1547 int32_t i = (bx>>4) + by;
4420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4421
4422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if(i > 175)
4423 return;
4424
4425 1547 bool ignorescreen=false;
4426 1547 bool ignoreffc=false;
4427
4428
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(get_bit(w->wscreengrid, i) != 0)
4429 {
4430 ignorescreen = true; dontignore = 0;
4431 }
4432
4433 1547 int32_t current_ffcombo = getFFCAt(fx,fy);
4434
4435
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1545 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
1547 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4436 {
4437 1545 ignoreffc = true;
4438 1545 }
4439
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4440 type2 = cNONE;
4441
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
2795 if(!isCuttableType(type) &&
4442
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 1248 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1248 times.
1248 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4443 {
4444 1248 ignorescreen = true;
4445 1248 }
4446
4447
2/4
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
3094 if(!isCuttableType(type2) &&
4448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4449 {
4450 1547 ignoreffc = true;
4451 1547 }
4452
4453 1547 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4454
4455
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1248 times.
1547 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4456 1547 byte skipsecrets = 0;
4457
2/2
✓ Branch 0 taken 1298 times.
✓ Branch 1 taken 249 times.
1547 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4458 {
4459
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
4460 {
4461 249 skipsecrets = 0;
4462 249 }
4463 else skipsecrets = 1;
4464 249 }
4465
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 1248 times.
✓ Branch 4 taken 1248 times.
✓ Branch 5 taken 1547 times.
1547 if((!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4466 {
4467
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2795 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4468 {
4469 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4470 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4471 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4472 }
4473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag == mfARMOS_SECRET)
4474 {
4475 s->data[i] = s->secretcombo[sSTAIRS];
4476 s->cset[i] = s->secretcset[sSTAIRS];
4477 s->sflag[i] = s->secretflag[sSTAIRS];
4478 sfx(tmpscr->secretsfx);
4479 }
4480
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4481 {
4482 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4483 {
4484 findentrance(bx,by,mfSWORD+i2,true);
4485 }
4486
4487 findentrance(bx,by,mfSTRIKE,true);
4488 }
4489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
299 else if(((flag2 >= 16)&&(flag2 <= 31)))
4490 {
4491 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4492 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4493 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4494 }
4495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag2 == mfARMOS_SECRET)
4496 {
4497 s->data[i] = s->secretcombo[sSTAIRS];
4498 s->cset[i] = s->secretcset[sSTAIRS];
4499 s->sflag[i] = s->secretflag[sSTAIRS];
4500 sfx(tmpscr->secretsfx);
4501 }
4502
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4503 {
4504 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4505 {
4506 findentrance(bx,by,mfSWORD+i2,true);
4507 }
4508
4509 findentrance(bx,by,mfSTRIKE,true);
4510 }
4511 else
4512 {
4513
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 50 times.
299 if(isCuttableNextType(type))
4514 {
4515 249 s->data[i]++;
4516 249 }
4517 else
4518 {
4519 50 s->data[i] = s->undercombo;
4520 50 s->cset[i] = s->undercset;
4521 50 s->sflag[i] = 0;
4522 }
4523
4524 //pausenow=true;
4525 }
4526 299 }
4527
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1248 else if(skipsecrets && (!ignorescreen || dontignore))
4528 {
4529 if(isCuttableNextType(type))
4530 {
4531 s->data[i]++;
4532 }
4533 else
4534 {
4535 s->data[i] = s->undercombo;
4536 s->cset[i] = s->undercset;
4537 s->sflag[i] = 0;
4538 }
4539 }
4540
4541
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
1547 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4542 {
4543 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4544 {
4545 findentrance(bx,by,mfSWORD+i2,true);
4546 }
4547
4548 findentrance(fx,fy,mfSTRIKE,true);
4549 }
4550
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 else if(!ignoreffc)
4551 {
4552 if(isCuttableNextType(type2))
4553 {
4554 s->ffcs[current_ffcombo].incData(1);
4555 }
4556 else
4557 {
4558 s->ffcs[current_ffcombo].setData(s->undercombo);
4559 s->ffcs[current_ffcombo].cset = s->undercset;
4560 }
4561 }
4562
4563
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
1547 if(!ignorescreen || dontignore)
4564 {
4565
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
299 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4566
4567
2/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4568 {
4569 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4570 sfx(tmpscr->secretsfx);
4571 }
4572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(isCuttableItemType(type))
4573 {
4574 299 int32_t it = -1;
4575 299 int32_t thedropset = -1;
4576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4577 {
4578 if ( combobuf[cid].usrflags&cflag11 )
4579 {
4580 it = combobuf[cid].attribytes[1];
4581 }
4582 else
4583 {
4584 it = select_dropitem(combobuf[cid].attribytes[1]);
4585 thedropset = combobuf[cid].attribytes[1];
4586 }
4587 }
4588 else
4589 {
4590 299 it = select_dropitem(12);
4591 299 thedropset = 12;
4592 }
4593
4594
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 99 times.
299 if(it!=-1)
4595 {
4596
4/8
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 99 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 99 times.
✗ Branch 7 not taken.
99 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4597 99 itm->from_dropset = thedropset;
4598 99 items.add(itm);
4599 99 }
4600 299 }
4601
4602
4603 299 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4604
4605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if(get_bit(quest_rules,qr_MORESOUNDS))
4606 {
4607
5/6
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 161 times.
✗ Branch 5 not taken.
299 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4608 {
4609 if (combobuf[cid].usrflags&cflag3)
4610 {
4611 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4612 }
4613 }
4614 else
4615 {
4616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if (combobuf[cid].usrflags&cflag3)
4617 {
4618 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4619 }
4620 299 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4621 }
4622 299 }
4623
4624
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
299 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4625
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(decotype > 3) decotype = 0;
4626
1/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4627
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
299 switch(decotype)
4628 {
4629 case -2: break; //nothing
4630 case -1:
4631 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4632 break;
4633
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
249 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4634
3/6
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
50 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4635 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4636 }
4637 299 }
4638
4639
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(!ignoreffc)
4640 {
4641 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4642
4643 if(isCuttableItemType(type2))
4644 {
4645 int32_t it=-1;
4646 int32_t thedropset=-1;
4647 if ( (combobuf[cid].usrflags&cflag2) )
4648 {
4649 if(combobuf[cid].usrflags&cflag11)
4650 it = combobuf[cid].attribytes[1];
4651 else
4652 {
4653 it = select_dropitem(combobuf[cid].attribytes[1]);
4654 thedropset = combobuf[cid].attribytes[1];
4655 }
4656 }
4657 else
4658 {
4659 int32_t r=zc_oldrand()%100;
4660
4661 if(r<15)
4662 {
4663 it=iHeart; // 15%
4664 }
4665 else if(r<35)
4666 {
4667 it=iRupy; // 20%
4668 }
4669 }
4670
4671 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4672 {
4673 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4674 itm->from_dropset = thedropset;
4675 items.add(itm);
4676 }
4677 }
4678
4679 if(get_bit(quest_rules,qr_MORESOUNDS))
4680 {
4681 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4682 {
4683 if (combobuf[cid].usrflags&cflag3)
4684 {
4685 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4686 }
4687 }
4688 else
4689 {
4690 if (combobuf[cid].usrflags&cflag3)
4691 {
4692 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4693 }
4694 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4695 }
4696 }
4697
4698 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4699 if(decotype > 3) decotype = 0;
4700 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4701 switch(decotype)
4702 {
4703 case -2: break; //nothing
4704 case -1:
4705 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4706 break;
4707 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4708 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4709 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4710 }
4711 }
4712 13020876 }
4713
4714 13020876 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4715 {
4716 /*
4717 int32_t par_item = w->parentitem;
4718 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4719 int32_t usewpn = -1;
4720 if ( par_item > -1 )
4721 {
4722 usewpn = itemsbuf[par_item].useweapon;
4723 }
4724 else if ( par_item == -1 && w->ScriptGenerated )
4725 {
4726 usewpn = w->useweapon;
4727 }
4728 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4729 */
4730
4731 13020876 byte dontignore = 0;
4732 13020876 byte dontignoreffc = 0;
4733
4734
4735
4736
4737
4738 //keep things inside the screen boundaries
4739 13020876 bx=vbound(bx, 0, 255);
4740 13020876 by=vbound(by, 0, 176);
4741 13020876 int32_t fx=vbound(bx, 0, 255);
4742 13020876 int32_t fy=vbound(by, 0, 176);
4743 13020876 int32_t cid = MAPCOMBO(bx,by);
4744
4745 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4746
3/4
✓ Branch 0 taken 13020876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✓ Branch 3 taken 13020217 times.
13020876 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf.data(), cid)) return;
4747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 659 times.
659 if ( MatchComboTrigger (w, combobuf.data(), cid) ) dontignore = 1;
4748
4749 //first things first
4750
2/4
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 659 times.
659 if(z>8||fakez>8) return;
4751
4752 //find out which combo row/column the coordinates are in
4753 659 bx &= 0xF0;
4754 659 by &= 0xF0;
4755
4756 659 int32_t flag = MAPFLAG(bx,by);
4757 659 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4758 659 int32_t flag3=0;
4759 659 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4760 659 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4761 659 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4762 659 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4763
4764
4/8
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 659 times.
659 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4765 flag3=mfWAND;
4766
4767
4/8
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 659 times.
659 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4768 flag3=mfSTRIKE;
4769
4770 659 int32_t i = (bx>>4) + by;
4771
4772
6/12
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 659 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 659 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 659 times.
659 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4773 659 return;
4774
4775 if(i > 175)
4776 return;
4777
4778 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4779
4780 //findentrance(bx,by,mfWAND,true);
4781 //findentrance(bx,by,mfSTRIKE,true);
4782 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4783 {
4784 if(flag3==mfWAND||flag3==mfSTRIKE)
4785 {
4786 findentrance(fx,fy,mfWAND,true);
4787 findentrance(fx,fy,mfSTRIKE,true);
4788 }
4789 }
4790
4791 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4792
4793 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4794 13020876 }
4795
4796 void HeroClass::check_slash_block(weapon *w)
4797 {
4798 //first things
4799
4800 int32_t par_item = w->parentitem;
4801 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4802 int32_t usewpn = -1;
4803 if ( par_item > -1 )
4804 {
4805 usewpn = itemsbuf[par_item].useweapon;
4806 }
4807 else if ( par_item == -1 && w->ScriptGenerated )
4808 {
4809 usewpn = w->useweapon;
4810 }
4811 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4812 if(usewpn != wSword) return;
4813
4814
4815 int32_t bx = 0, by = 0;
4816 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
4817 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
4818 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
4819 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
4820 //keep things inside the screen boundaries
4821 bx=vbound(bx, 0, 255);
4822 by=vbound(by, 0, 176);
4823 int32_t fx=vbound(bx, 0, 255);
4824 int32_t fy=vbound(by, 0, 176);
4825
4826 int32_t cid = MAPCOMBO(bx,by);
4827
4828 //find out which combo row/column the coordinates are in
4829 bx &= 0xF0;
4830 by &= 0xF0;
4831
4832 int32_t type = COMBOTYPE(bx,by);
4833 int32_t type2 = FFCOMBOTYPE(fx,fy);
4834 int32_t flag = MAPFLAG(bx,by);
4835 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4836 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4837 int32_t i = (bx>>4) + by;
4838
4839 if(i > 175)
4840 {
4841 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
4842 return;
4843 }
4844
4845 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4846 type = cNONE;
4847 bool ignorescreen=false;
4848 bool ignoreffc=false;
4849
4850 if(get_bit(screengrid, i) != 0)
4851 {
4852 ignorescreen = true;
4853 }
4854
4855 int32_t current_ffcombo = getFFCAt(fx,fy);
4856
4857 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4858 {
4859 ignoreffc = true;
4860 }
4861 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4862 type2 = cNONE;
4863 if(!isCuttableType(type) &&
4864 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4865 {
4866 ignorescreen = true;
4867 }
4868
4869 if(!isCuttableType(type2) &&
4870 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4871 {
4872 ignoreffc = true;
4873 }
4874
4875 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4876
4877 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
4878
4879 if(!ignorescreen)
4880 {
4881 if((flag >= 16)&&(flag <= 31))
4882 {
4883 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4884 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4885 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4886 }
4887 else if(flag == mfARMOS_SECRET)
4888 {
4889 s->data[i] = s->secretcombo[sSTAIRS];
4890 s->cset[i] = s->secretcset[sSTAIRS];
4891 s->sflag[i] = s->secretflag[sSTAIRS];
4892 sfx(tmpscr->secretsfx);
4893 }
4894 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4895 {
4896 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4897 {
4898 findentrance(bx,by,mfSWORD+i2,true);
4899 }
4900
4901 findentrance(bx,by,mfSTRIKE,true);
4902 }
4903 else if(((flag2 >= 16)&&(flag2 <= 31)))
4904 {
4905 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4906 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4907 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4908 }
4909 else if(flag2 == mfARMOS_SECRET)
4910 {
4911 s->data[i] = s->secretcombo[sSTAIRS];
4912 s->cset[i] = s->secretcset[sSTAIRS];
4913 s->sflag[i] = s->secretflag[sSTAIRS];
4914 sfx(tmpscr->secretsfx);
4915 }
4916 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4917 {
4918 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4919 {
4920 findentrance(bx,by,mfSWORD+i2,true);
4921 }
4922
4923 findentrance(bx,by,mfSTRIKE,true);
4924 }
4925 else
4926 {
4927 if(isCuttableNextType(type))
4928 {
4929 s->data[i]++;
4930 }
4931 else
4932 {
4933 s->data[i] = s->undercombo;
4934 s->cset[i] = s->undercset;
4935 s->sflag[i] = 0;
4936 }
4937
4938 //pausenow=true;
4939 }
4940 }
4941
4942 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4943 {
4944 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4945 {
4946 findentrance(bx,by,mfSWORD+i2,true);
4947 }
4948
4949 findentrance(fx,fy,mfSTRIKE,true);
4950 }
4951 else if(!ignoreffc)
4952 {
4953 if(isCuttableNextType(type2))
4954 {
4955 s->ffcs[current_ffcombo].incData(1);
4956 }
4957 else
4958 {
4959 s->ffcs[current_ffcombo].setData(s->undercombo);
4960 s->ffcs[current_ffcombo].cset = s->undercset;
4961 }
4962 }
4963
4964 if(!ignorescreen)
4965 {
4966 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
4967
4968 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4969 {
4970 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4971 sfx(tmpscr->secretsfx);
4972 }
4973 else if(isCuttableItemType(type))
4974 {
4975 int32_t it = -1;
4976 int32_t thedropset = -1;
4977 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4978 {
4979 if ( combobuf[cid].usrflags&cflag11 )
4980 {
4981 it = combobuf[cid].attribytes[1];
4982 }
4983 else
4984 {
4985 it = select_dropitem(combobuf[cid].attribytes[1]);
4986 thedropset = combobuf[cid].attribytes[1];
4987 }
4988 }
4989 else
4990 {
4991 it = select_dropitem(12);
4992 thedropset = 12;
4993 }
4994
4995 if(it!=-1)
4996 {
4997 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4998 itm->from_dropset = thedropset;
4999 items.add(itm);
5000 }
5001 }
5002
5003 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5004
5005 if(get_bit(quest_rules,qr_MORESOUNDS))
5006 {
5007 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5008 {
5009 if (combobuf[cid].usrflags&cflag3)
5010 {
5011 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5012 }
5013 }
5014 else
5015 {
5016 if (combobuf[cid].usrflags&cflag3)
5017 {
5018 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5019 }
5020 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5021 }
5022 }
5023
5024 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5025 if(decotype > 3) decotype = 0;
5026 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5027 switch(decotype)
5028 {
5029 case -2: break; //nothing
5030 case -1:
5031 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5032 break;
5033 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5034 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5035 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5036 }
5037 }
5038
5039 if(!ignoreffc)
5040 {
5041 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5042
5043 if(isCuttableItemType(type2))
5044 {
5045 int32_t it=-1;
5046 int32_t thedropset = -1;
5047 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5048 {
5049 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5050 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5051 else
5052 {
5053 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5054 it = select_dropitem(thedropset);
5055 }
5056 }
5057 else
5058 {
5059 it = select_dropitem(12);
5060 thedropset = 12;
5061 }
5062
5063 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5064 {
5065 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5066 itm->from_dropset = thedropset;
5067 items.add(itm);
5068 }
5069 }
5070
5071 if(get_bit(quest_rules,qr_MORESOUNDS))
5072 {
5073 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5074 {
5075 if (combobuf[cid].usrflags&cflag3)
5076 {
5077 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5078 }
5079 }
5080 else
5081 {
5082 if (combobuf[cid].usrflags&cflag3)
5083 {
5084 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5085 }
5086 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5087 }
5088 }
5089
5090 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5091 if(decotype > 3) decotype = 0;
5092 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5093 switch(decotype)
5094 {
5095 case -2: break; //nothing
5096 case -1:
5097 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5098 break;
5099 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5100 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5101 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5102 }
5103 }
5104 }
5105
5106 //TODO: Boomerang that cuts bushes. -L
5107 /*void HeroClass::slash_bush()
5108 {
5109
5110 }*/
5111
5112 31820 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5113 {
5114 //keep things inside the screen boundaries
5115 31820 bx=vbound(bx, 0, 255);
5116 31820 by=vbound(by, 0, 176);
5117 31820 int32_t fx=vbound(bx, 0, 255);
5118 31820 int32_t fy=vbound(by, 0, 176);
5119 31820 int32_t cid = MAPCOMBO(bx,by);
5120
5121 //first things first
5122
2/4
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31820 times.
31820 if(z>8||fakez>8) return;
5123
5124 //find out which combo row/column the coordinates are in
5125 31820 bx &= 0xF0;
5126 31820 by &= 0xF0;
5127
5128 31820 int32_t flag = MAPFLAG(bx,by);
5129 31820 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5130 31820 int32_t flag3=0;
5131 31820 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5132 31820 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5133 31820 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5134 31820 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5135
5136
4/8
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31820 times.
31820 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5137 flag3=mfWAND;
5138
5139
4/8
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31820 times.
31820 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5140 flag3=mfSTRIKE;
5141
5142 31820 int32_t i = (bx>>4) + by;
5143
5144
6/12
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31820 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 31820 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 31820 times.
✗ Branch 11 not taken.
31820 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5145 31820 return;
5146
5147 if(i > 175)
5148 return;
5149
5150 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5151
5152 //findentrance(bx,by,mfWAND,true);
5153 //findentrance(bx,by,mfSTRIKE,true);
5154 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5155 {
5156 if(flag3==mfWAND||flag3==mfSTRIKE)
5157 {
5158 findentrance(fx,fy,mfWAND,true);
5159 findentrance(fx,fy,mfSTRIKE,true);
5160 }
5161 }
5162
5163 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5164 31820 }
5165
5166 1704 void HeroClass::check_pound_block(int bx, int by, weapon* w)
5167 {
5168
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1704 if(w && w->no_triggers()) return;
5169
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1704 if(w && w->id == wHammer && getHammerState() < 3)
5170 return;
5171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 if(get_bit(quest_rules,qr_POUNDLAYERS1AND2))
5172 {
5173 check_pound_block_layer(bx,by,1,w);
5174 check_pound_block_layer(bx,by,2,w);
5175 }
5176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 auto* grid = w ? w->wscreengrid : screengrid;
5177 //keep things inside the screen boundaries
5178 1704 bx=vbound(bx, 0, 255);
5179 1704 by=vbound(by, 0, 176);
5180 1704 int32_t fx=vbound(bx, 0, 255);
5181 1704 int32_t fy=vbound(by, 0, 176);
5182 1704 int32_t cid = MAPCOMBO(bx,by);
5183
5184 //first things first
5185
2/4
✓ Branch 0 taken 1704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1704 times.
1704 if(z>8||fakez>8) return;
5186
5187 //find out which combo row/column the coordinates are in
5188 1704 bx &= 0xF0;
5189 1704 by &= 0xF0;
5190
5191 1704 int32_t type = COMBOTYPE(bx,by);
5192 1704 int32_t type2 = FFCOMBOTYPE(fx,fy);
5193 1704 int32_t flag = MAPFLAG(bx,by);
5194 1704 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5195 1704 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5196 1704 int32_t i = (bx>>4) + by;
5197
5198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 if(i > 175)
5199 return;
5200
5201 1704 bool ignorescreen=false;
5202 1704 bool ignoreffc=false;
5203 1704 bool pound=false;
5204
5205
6/10
✓ Branch 0 taken 1646 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 1646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1646 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1646 times.
1704 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5206 1646 ignorescreen = true; // Affect only FFCs
5207
5208
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 27 times.
1704 if(get_bit(grid, i) != 0)
5209 27 ignorescreen = true;
5210
5211 1704 int32_t current_ffcombo = getFFCAt(fx,fy);
5212
5213
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1703 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1704 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5214 1703 ignoreffc = true;
5215
5216
3/6
✓ Branch 0 taken 1704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1704 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1704 times.
1704 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5217 1704 ignoreffc = true;
5218
5219
3/4
✓ Branch 0 taken 1654 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
1704 if(ignorescreen && ignoreffc) // Nothing to do.
5220 1654 return;
5221
5222 50 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5223
5224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(!ignorescreen)
5225 {
5226
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
50 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5227 {
5228 findentrance(bx,by,mfHAMMER,true);
5229 findentrance(bx,by,mfSTRIKE,true);
5230 }
5231
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
50 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5232 {
5233 findentrance(bx,by,mfHAMMER,true);
5234 findentrance(bx,by,mfSTRIKE,true);
5235 }
5236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 else if((flag >= 16)&&(flag <= 31))
5237 {
5238 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5239 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5240 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5241 }
5242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 else if(flag == mfARMOS_SECRET)
5243 {
5244 s->data[i] = s->secretcombo[sSTAIRS];
5245 s->cset[i] = s->secretcset[sSTAIRS];
5246 s->sflag[i] = s->secretflag[sSTAIRS];
5247 sfx(tmpscr->secretsfx);
5248 }
5249
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 else if((flag2 >= 16)&&(flag2 <= 31))
5250 {
5251 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5252 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5253 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5254 }
5255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 else if(flag2 == mfARMOS_SECRET)
5256 {
5257 s->data[i] = s->secretcombo[sSTAIRS];
5258 s->cset[i] = s->secretcset[sSTAIRS];
5259 s->sflag[i] = s->secretflag[sSTAIRS];
5260 sfx(tmpscr->secretsfx);
5261 }
5262 50 else pound = true;
5263 50 }
5264
5265
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(!ignoreffc)
5266 {
5267 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5268 {
5269 findentrance(fx,fy,mfHAMMER,true);
5270 findentrance(fx,fy,mfSTRIKE,true);
5271 }
5272 else
5273 {
5274 s->ffcs[current_ffcombo].incData(1);
5275 }
5276 }
5277
5278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(!ignorescreen)
5279 {
5280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(pound)
5281 50 s->data[i]+=1;
5282
5283 50 set_bit(grid,i,1);
5284
5285
2/8
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
50 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5286 {
5287 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5288 sfx(tmpscr->secretsfx);
5289 }
5290
5291
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
50 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5292 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5293
5294 50 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5295 50 }
5296
5297
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(!ignoreffc)
5298 {
5299 set_bit(ffcgrid,current_ffcombo,1);
5300
5301 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5302 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5303 }
5304
5305 50 return;
5306 1704 }
5307
5308 void HeroClass::check_pound_block_layer(int bx, int by, int lyr, weapon* w)
5309 {
5310 if(lyr < 1 || lyr > 2) return; //sanity
5311 //keep things inside the screen boundaries
5312 bx=vbound(bx, 0, 255);
5313 by=vbound(by, 0, 176);
5314 int32_t cid = MAPCOMBOL(lyr,bx,by);
5315 newcombo const& scr_cmb = combobuf[cid];
5316 auto* grid = w ? w->wscreengrid_layer[lyr-1] : screengrid_layer[lyr-1];
5317
5318 //first things first
5319 if(z>8||fakez>8) return;
5320
5321 //find out which combo row/column the coordinates are in
5322 bx &= 0xF0;
5323 by &= 0xF0;
5324
5325 int32_t type = scr_cmb.type;
5326 int32_t flag = MAPFLAGL(lyr,bx,by);
5327 int32_t flag2 = scr_cmb.flag;
5328 int32_t i = (bx>>4) + by;
5329
5330 if(i > 175)
5331 return;
5332
5333 bool pound=false;
5334
5335 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5336 return;
5337
5338 if(get_bit(grid, i) != 0)
5339 return;
5340
5341 mapscr *s = FFCore.tempScreens[lyr];
5342
5343 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5344 {
5345 findentrance(bx,by,mfHAMMER,true);
5346 findentrance(bx,by,mfSTRIKE,true);
5347 }
5348 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5349 {
5350 findentrance(bx,by,mfHAMMER,true);
5351 findentrance(bx,by,mfSTRIKE,true);
5352 }
5353 else if((flag >= 16)&&(flag <= 31))
5354 {
5355 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5356 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5357 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5358 }
5359 else if(flag == mfARMOS_SECRET)
5360 {
5361 s->data[i] = s->secretcombo[sSTAIRS];
5362 s->cset[i] = s->secretcset[sSTAIRS];
5363 s->sflag[i] = s->secretflag[sSTAIRS];
5364 sfx(tmpscr->secretsfx);
5365 }
5366 else if((flag2 >= 16)&&(flag2 <= 31))
5367 {
5368 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5369 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5370 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5371 }
5372 else if(flag2 == mfARMOS_SECRET)
5373 {
5374 s->data[i] = s->secretcombo[sSTAIRS];
5375 s->cset[i] = s->secretcset[sSTAIRS];
5376 s->sflag[i] = s->secretflag[sSTAIRS];
5377 sfx(tmpscr->secretsfx);
5378 }
5379 else pound = true;
5380
5381 if(pound)
5382 s->data[i]+=1;
5383
5384 set_bit(grid,i,1);
5385
5386 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5387 {
5388 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5389 sfx(tmpscr->secretsfx);
5390 }
5391
5392 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5393 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5394
5395 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5396 }
5397
5398 void HeroClass::check_wand_block(weapon *w)
5399 {
5400
5401 int32_t par_item = w->parentitem;
5402 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5403 int32_t usewpn = -1;
5404 if ( par_item > -1 )
5405 {
5406 usewpn = itemsbuf[par_item].useweapon;
5407 }
5408 else if ( par_item == -1 && w->ScriptGenerated )
5409 {
5410 usewpn = w->useweapon;
5411 }
5412 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5413 if(usewpn != wWand) return;
5414
5415
5416 int32_t bx = 0, by = 0;
5417 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
5418 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
5419
5420 //keep things inside the screen boundaries
5421 bx=vbound(bx, 0, 255);
5422 by=vbound(by, 0, 176);
5423 int32_t fx=vbound(bx, 0, 255);
5424 int32_t fy=vbound(by, 0, 176);
5425 int32_t cid = MAPCOMBO(bx,by);
5426 //first things first
5427 if(z>8||fakez>8) return;
5428
5429 //find out which combo row/column the coordinates are in
5430 bx &= 0xF0;
5431 by &= 0xF0;
5432
5433 int32_t flag = MAPFLAG(bx,by);
5434 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5435 int32_t flag3=0;
5436 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5437 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5438 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5439 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5440
5441 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5442 flag3=mfWAND;
5443
5444 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5445 flag3=mfSTRIKE;
5446
5447 int32_t i = (bx>>4) + by;
5448
5449 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5450 return;
5451
5452 if(i > 175)
5453 return;
5454
5455 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5456
5457 //findentrance(bx,by,mfWAND,true);
5458 //findentrance(bx,by,mfSTRIKE,true);
5459 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5460 {
5461 if(flag3==mfWAND||flag3==mfSTRIKE)
5462 {
5463 findentrance(fx,fy,mfWAND,true);
5464 findentrance(fx,fy,mfSTRIKE,true);
5465 }
5466 }
5467
5468 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5469 }
5470
5471 //defend results should match defence types.
5472 //RETURN VALUES:
5473 // -1 iGNORE WEAPON
5474 // 0 No effects
5475 // 1 Effects, weapon is not ignored or removed
5476 6603 int32_t HeroClass::defend(weapon *w)
5477 {
5478 6603 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5479
1/25
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
6603 switch(def)
5480 {
5481 6603 case edNORMAL: return 1;
5482 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5483 {
5484 w->power *= 0.5;
5485 return 1;
5486 }
5487 case edQUARTDAMAGE:
5488 {
5489 w->power *= 0.25;
5490 return 1;
5491 }
5492 case edSTUNONLY:
5493 {
5494 setStunClock(120);
5495 return 1;
5496 }
5497 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5498 {
5499 if (w->power > 0)
5500 {
5501 setStunClock(120);
5502 return 1;
5503 }
5504 else
5505 {
5506 sfx(WAV_CHINK,pan(int32_t(x)));
5507 w->dead = 0;
5508 return -1;
5509 }
5510 }
5511 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5512 {
5513 if (w->power > 0)
5514 {
5515 setStunClock(120);
5516 return 1;
5517 }
5518 else
5519 {
5520 return -1;
5521 }
5522 }
5523 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5524 {
5525 if (w->power < 1)
5526 {
5527 sfx(WAV_CHINK,pan(int32_t(x)));
5528 w->dead = 0;
5529 return -1;
5530 }
5531 else
5532 {
5533 return 1;
5534 }
5535 }
5536 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5537 {
5538 if (w->power < 2)
5539 {
5540 sfx(WAV_CHINK,pan(int32_t(x)));
5541 w->dead = 0;
5542 return -1;
5543 }
5544 else
5545 {
5546 return 1;
5547 }
5548 }
5549 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5550 {
5551 if (w->power < 4)
5552 {
5553 sfx(WAV_CHINK,pan(int32_t(x)));
5554 w->dead = 0;
5555 return -1;
5556 }
5557 else
5558 {
5559 return 1;
5560 }
5561 }
5562 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5563 {
5564 if (w->power < 6)
5565 {
5566 sfx(WAV_CHINK,pan(int32_t(x)));
5567 w->dead = 0;
5568 return -1;
5569 }
5570 else
5571 {
5572 return 1;
5573 }
5574 }
5575 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5576 {
5577 if (w->power < 8)
5578 {
5579 sfx(WAV_CHINK,pan(int32_t(x)));
5580 w->dead = 0;
5581 return -1;
5582 }
5583 else
5584 {
5585 return 1;
5586 }
5587 }
5588 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5589 {
5590 sfx(WAV_CHINK,pan(int32_t(x)));
5591 w->dead = 0;
5592 return -1;
5593 }
5594 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5595 {
5596 if (w->power < 1)
5597 {
5598 return -1;
5599 }
5600 else return 1;
5601 }
5602 case edIGNORE: // : IMPLEMENTED : Do Nothing
5603 {
5604 return -1;
5605 }
5606 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5607 {
5608 game->set_life(0);
5609 return 1;
5610 }
5611 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5612 {
5613 if (w->power < 10)
5614 {
5615 sfx(WAV_CHINK,pan(int32_t(x)));
5616 w->dead = 0;
5617 return -1;
5618 }
5619 else
5620 {
5621 return 1;
5622 }
5623 }
5624 case ed2x: // : IMPLEMENTED : Double damage.
5625 {
5626 w->power *= 2;
5627 return 1;
5628 }
5629 case ed3x: // : IMPLEMENTED : Triple Damage.
5630 {
5631 w->power *= 3;
5632 return 1;
5633 }
5634 case ed4x: // : IMPLEMENTED : 4x damage.
5635 {
5636 w->power *= 4;
5637 return 1;
5638 }
5639 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5640 {
5641 //sfx(WAV_HEAL,pan(int32_t(x)));
5642 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5643 w->dead = 0;
5644 return -1;
5645 }
5646
5647 case edFREEZE: return 1; //Not IMPLEMENTED
5648
5649 case edLEVELDAMAGE: //Damage * item level
5650 {
5651 w->power *= w->family_level;
5652 return 1;
5653 }
5654 case edLEVELREDUCTION: //Damage / item level
5655 {
5656 if ( w->family_level > 0 )
5657 {
5658 w->power /= w->family_level;
5659 }
5660 else w->power = 0;
5661 return 1;
5662 }
5663
5664 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5665 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5666 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5667 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5668
5669 //edSHOCK, //buzz blob
5670
5671
5672 case edBREAKSHIELD: //destroy the player's present shield
5673 {
5674 w->power = 0;
5675 w->dead = 0;
5676 int32_t itemid = getCurrentShield();
5677 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5678 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5679 game->set_item(itemid, false);
5680 //Remove Hero's shield
5681 return -1;
5682 }
5683
5684
5685
5686 default: return 0;
5687 }
5688 6603 }
5689 ALLEGRO_COLOR HeroClass::hitboxColor(byte opacity) const
5690 {
5691 return al_map_rgba(0,0,255,opacity);
5692 }
5693 6401 int32_t HeroClass::compareDir(int32_t other)
5694 {
5695
5/6
✓ Branch 0 taken 6396 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6396 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 6399 times.
6401 if(other != NORMAL_DIR(other))
5696 2 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5697 6399 int32_t ret = 0;
5698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6399 times.
6399 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5699
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
✓ Branch 2 taken 1045 times.
✓ Branch 3 taken 2004 times.
✓ Branch 4 taken 1982 times.
6399 switch(d)
5700 {
5701 case up:
5702 {
5703
3/3
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 526 times.
✓ Branch 2 taken 519 times.
1368 switch(X_DIR(other))
5704 {
5705 case left:
5706 526 ret |= CMPDIR_RIGHT;
5707 526 break;
5708 case right:
5709 519 ret |= CMPDIR_LEFT;
5710 519 break;
5711 }
5712
3/3
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 229 times.
✓ Branch 2 taken 980 times.
1368 switch(Y_DIR(other))
5713 {
5714 case up:
5715 229 ret |= CMPDIR_BACK;
5716 229 break;
5717 case down:
5718 980 ret |= CMPDIR_FRONT;
5719 980 break;
5720 }
5721 1368 break;
5722 }
5723 case down:
5724 {
5725
3/3
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 405 times.
1045 switch(X_DIR(other))
5726 {
5727 case left:
5728 330 ret |= CMPDIR_LEFT;
5729 330 break;
5730 case right:
5731 405 ret |= CMPDIR_RIGHT;
5732 405 break;
5733 }
5734
3/3
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 731 times.
✓ Branch 2 taken 180 times.
1045 switch(Y_DIR(other))
5735 {
5736 case up:
5737 731 ret |= CMPDIR_FRONT;
5738 731 break;
5739 case down:
5740 180 ret |= CMPDIR_BACK;
5741 180 break;
5742 }
5743 1045 break;
5744 }
5745 case left:
5746 {
5747
3/3
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 1620 times.
2004 switch(X_DIR(other))
5748 {
5749 case left:
5750 293 ret |= CMPDIR_BACK;
5751 293 break;
5752 case right:
5753 1620 ret |= CMPDIR_FRONT;
5754 1620 break;
5755 }
5756
3/3
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 674 times.
2004 switch(Y_DIR(other))
5757 {
5758 case up:
5759 613 ret |= CMPDIR_LEFT;
5760 613 break;
5761 case down:
5762 674 ret |= CMPDIR_RIGHT;
5763 674 break;
5764 }
5765 2004 break;
5766 }
5767 case right:
5768 {
5769
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 1630 times.
✓ Branch 2 taken 259 times.
1982 switch(X_DIR(other))
5770 {
5771 case left:
5772 1630 ret |= CMPDIR_FRONT;
5773 1630 break;
5774 case right:
5775 259 ret |= CMPDIR_BACK;
5776 259 break;
5777 }
5778
3/3
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 510 times.
✓ Branch 2 taken 715 times.
1982 switch(Y_DIR(other))
5779 {
5780 case up:
5781 510 ret |= CMPDIR_RIGHT;
5782 510 break;
5783 case down:
5784 715 ret |= CMPDIR_LEFT;
5785 715 break;
5786 }
5787 1982 break;
5788 }
5789 }
5790 6399 return ret;
5791 6401 }
5792
5793 6401 bool compareShield(int32_t cmpdir, itemdata const& shield)
5794 {
5795
1/2
✓ Branch 0 taken 6401 times.
✗ Branch 1 not taken.
6401 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
5796
1/2
✓ Branch 0 taken 6401 times.
✗ Branch 1 not taken.
6401 if(standard) //Use standard sides, either a passive shield, or a held active shield
5797 {
5798
3/4
✓ Branch 0 taken 4961 times.
✓ Branch 1 taken 1440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4961 times.
6401 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
5799 4961 return true;
5800
3/4
✓ Branch 0 taken 961 times.
✓ Branch 1 taken 479 times.
✓ Branch 2 taken 961 times.
✗ Branch 3 not taken.
1440 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
5801 return true;
5802
3/4
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 833 times.
✓ Branch 2 taken 607 times.
✗ Branch 3 not taken.
1440 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
5803 return true;
5804
3/4
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 645 times.
1440 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
5805 return true;
5806 1440 }
5807 else //Active Shield that is NOT held down
5808 {
5809 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
5810 return true;
5811 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
5812 return true;
5813 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
5814 return true;
5815 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
5816 return true;
5817 }
5818 1440 return false;
5819 6401 }
5820
5821 5755638 int32_t HeroClass::EwpnHit()
5822 {
5823
2/2
✓ Branch 0 taken 5752747 times.
✓ Branch 1 taken 4053865 times.
9806612 for(int32_t i=0; i<Ewpns.Count(); i++)
5824 {
5825
2/2
✓ Branch 0 taken 4047262 times.
✓ Branch 1 taken 6603 times.
4053865 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
5826 {
5827 6603 weapon *ew = (weapon*)(Ewpns.spr(i));
5828
5829
3/6
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6603 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6603 times.
6603 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
5830 break;
5831
5832 6603 int32_t stompid = current_item_id(itype_stompboots);
5833
5834
5/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6597 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6603 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
5835
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((z+fakez) > (ew->z+(ew->fakez))) ||
5836
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
5837 {
5838 itemdata const& stomp = itemsbuf[stompid];
5839 bool remove = false;
5840 switch(ew->id)
5841 {
5842 case ewFireball2:
5843 case ewFireball:
5844 if(ew->type & 1) //Boss fireball
5845 {
5846 if(stomp.misc2 & (shFIREBALL2))
5847 remove = true;
5848 }
5849 else
5850 {
5851 if(stomp.misc2 & (shFIREBALL))
5852 remove = true;
5853 }
5854
5855 break;
5856
5857 case ewMagic:
5858 if((stomp.misc2 & shMAGIC))
5859 remove = true;
5860 break;
5861
5862 case ewSword:
5863 if((stomp.misc2 & shSWORD))
5864 remove = true;
5865
5866 break;
5867
5868 case ewFlame:
5869 if((stomp.misc2 & shFLAME))
5870 remove = true;
5871
5872 break;
5873
5874 case ewRock:
5875 if((stomp.misc2 & shROCK))
5876 remove = true;
5877
5878 break;
5879
5880 case ewArrow:
5881 if((stomp.misc2 & shARROW))
5882 remove = true;
5883
5884 break;
5885
5886 case ewBrang:
5887 if((stomp.misc2 & shBRANG))
5888 remove = true;
5889
5890 break;
5891
5892 default: // Just throw the script weapons in here...
5893 if(ew->id>=wScript1 && ew->id<=wScript10)
5894 {
5895 if((stomp.misc2 & shSCRIPT))
5896 remove = true;
5897 }
5898
5899 break;
5900 }
5901 if (remove)
5902 {
5903 ew->onhit(false);
5904 sfx(WAV_CHINK,pan(x.getInt()));
5905 continue;
5906 }
5907 }
5908
5909 6603 int32_t defresult = defend(ew);
5910
1/2
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
6603 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
5911
5912
2/2
✓ Branch 0 taken 6602 times.
✓ Branch 1 taken 1 times.
6603 if(ew->id==ewWind)
5913 {
5914 1 xofs=1000;
5915 1 action=freeze; FFCore.setHeroAction(freeze);
5916 1 ew->misc=999; // in enemy wind
5917 1 attackclk=0;
5918 1 return -1;
5919 }
5920
5921
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6591 times.
6602 switch(ew->id)
5922 {
5923 case ewLitBomb:
5924 case ewBomb:
5925 case ewLitSBomb:
5926 case ewSBomb:
5927 11 return i;
5928 }
5929
5930 6591 int32_t itemid = getCurrentShield(false);
5931
4/6
✓ Branch 0 taken 6399 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 6399 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6399 times.
6591 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
5932 192 return i;
5933 6399 itemdata const& shield = itemsbuf[itemid];
5934 6399 bool allow_inactive = (shield.flags & ITEM_FLAG9);
5935 6399 auto cmpdir = compareDir(ew->dir);
5936 6399 bool hitshield = compareShield(cmpdir, shield);
5937
5938
12/20
✓ Branch 0 taken 6399 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6399 times.
✓ Branch 4 taken 5133 times.
✓ Branch 5 taken 1266 times.
✓ Branch 6 taken 5133 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5105 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 5105 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5105 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5105 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 5105 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5105 times.
✗ Branch 19 not taken.
6399 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
5939 1294 return i;
5940
5941
2/2
✓ Branch 0 taken 4061 times.
✓ Branch 1 taken 1044 times.
5105 if(!hitshield)
5942 1044 return i;
5943
5944 4061 paymagiccost(itemid);
5945
5946 4061 bool reflect = false;
5947
5948
7/8
✓ Branch 0 taken 2227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 545 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 349 times.
✓ Branch 5 taken 232 times.
✓ Branch 6 taken 227 times.
✓ Branch 7 taken 211 times.
4061 switch(ew->id)
5949 {
5950 case ewFireball2:
5951 case ewFireball:
5952
2/2
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 2076 times.
2227 if(ew->type & 1) //Boss fireball
5953 {
5954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(!(shield.misc1 & (shFIREBALL2)))
5955 151 return i;
5956
5957 reflect = ((shield.misc2 & shFIREBALL2) != 0);
5958 }
5959 else
5960 {
5961
2/2
✓ Branch 0 taken 1978 times.
✓ Branch 1 taken 98 times.
2076 if(!(shield.misc1 & (shFIREBALL)))
5962 98 return i;
5963
5964 1978 reflect = ((shield.misc2 & shFIREBALL) != 0);
5965 }
5966
5967 1978 break;
5968
5969 case ewMagic:
5970
2/2
✓ Branch 0 taken 517 times.
✓ Branch 1 taken 28 times.
545 if(!(shield.misc1 & shMAGIC))
5971 28 return i;
5972
5973 517 reflect = ((shield.misc2 & shMAGIC) != 0);
5974 517 break;
5975
5976 case ewSword:
5977
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 26 times.
270 if(!(shield.misc1 & shSWORD))
5978 26 return i;
5979
5980 244 reflect = ((shield.misc2 & shSWORD) != 0);
5981 244 break;
5982
5983 case ewFlame:
5984
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 46 times.
349 if(!(shield.misc1 & shFLAME))
5985 46 return i;
5986
5987 303 reflect = ((shield.misc2 & shFLAME) != 0); // Actually isn't reflected.
5988 303 break;
5989
5990 case ewRock:
5991
1/2
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
232 if(!(shield.misc1 & shROCK))
5992 return i;
5993
5994 232 reflect = (shield.misc2 & shROCK);
5995 232 break;
5996
5997 case ewArrow:
5998
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 if(!(shield.misc1 & shARROW))
5999 return i;
6000
6001 227 reflect = ((shield.misc2 & shARROW) != 0); // Actually isn't reflected.
6002 227 break;
6003
6004 case ewBrang:
6005
1/2
✓ Branch 0 taken 211 times.
✗ Branch 1 not taken.
211 if(!(shield.misc1 & shBRANG))
6006 return i;
6007
6008 211 break;
6009
6010 default: // Just throw the script weapons in here...
6011 if(ew->id>=wScript1 && ew->id<=wScript10)
6012 {
6013 if(!(shield.misc1 & shSCRIPT))
6014 return i;
6015
6016 reflect = ((shield.misc2 & shSCRIPT) != 0);
6017 }
6018
6019 break;
6020 }
6021
6022
3/4
✓ Branch 0 taken 1097 times.
✓ Branch 1 taken 2615 times.
✓ Branch 2 taken 1097 times.
✗ Branch 3 not taken.
3712 if(reflect && (ew->unblockable&WPNUNB_REFL))
6023 reflect = false;
6024
3/4
✓ Branch 0 taken 2615 times.
✓ Branch 1 taken 1097 times.
✓ Branch 2 taken 2615 times.
✗ Branch 3 not taken.
3712 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6025 return i;
6026
6027 3712 int32_t oldid = ew->id;
6028 3712 ew->onhit(false, reflect ? 2 : 1, dir);
6029
6030
2/2
✓ Branch 0 taken 2615 times.
✓ Branch 1 taken 1097 times.
3712 if(ew->id != oldid) // changed type from ewX to wX
6031 {
6032 // ew->power*=game->get_hero_dmgmult();
6033 1097 Lwpns.add(ew);
6034 1097 Ewpns.remove(ew);
6035 1097 ew->isLWeapon = true; //Make sure this gets set everywhere!
6036 1097 }
6037
6038
2/2
✓ Branch 0 taken 3373 times.
✓ Branch 1 taken 339 times.
3712 if(ew->id==wRefMagic)
6039 {
6040 339 ew->ignoreHero=true;
6041 339 ew->ignorecombo=-1;
6042 339 }
6043
6044 3712 sfx(shield.usesound,pan(x.getInt()));
6045 3712 }
6046 4050974 }
6047
6048 5752747 return -1;
6049 5755638 }
6050
6051 5755640 int32_t HeroClass::LwpnHit() //only here to check magic hits
6052 {
6053
2/2
✓ Branch 0 taken 5646451 times.
✓ Branch 1 taken 2348673 times.
7995124 for(int32_t i=0; i<Lwpns.Count(); i++)
6054
2/2
✓ Branch 0 taken 2239484 times.
✓ Branch 1 taken 109189 times.
2348673 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6055 {
6056 109189 weapon *lw = (weapon*)(Lwpns.spr(i));
6057
6058
2/2
✓ Branch 0 taken 105952 times.
✓ Branch 1 taken 3237 times.
109189 if((lw->ignoreHero)==true)
6059 3237 break;
6060
6061
5/8
✓ Branch 0 taken 105952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105950 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 105950 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 105950 times.
105952 if (!(lw->id == wRefFireball || lw->id == wRefMagic || lw->id == wRefBeam || lw->id == wRefRock)) return -1;
6062 2 int32_t itemid = getCurrentShield(false);
6063
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6064 return i;
6065 2 itemdata const& shield = itemsbuf[itemid];
6066 2 auto cmpdir = compareDir(lw->dir);
6067 2 bool hitshield = compareShield(cmpdir, shield);
6068 2 bool reflect = false;
6069
6070
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 switch(lw->id)
6071 {
6072 case wRefFireball:
6073 if(itemid<0)
6074 return i;
6075
6076 if(lw->type & 1) //Boss fireball
6077 return i;
6078
6079 if(!(shield.misc1 & (shFIREBALL)))
6080 return i;
6081
6082 reflect = ((shield.misc2 & shFIREBALL) != 0);
6083 break;
6084
6085 case wRefMagic:
6086
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemid<0)
6087 return i;
6088
6089
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(shield.misc1 & shMAGIC))
6090 return i;
6091
6092 2 reflect = ((shield.misc2 & shMAGIC) != 0);
6093 2 break;
6094
6095 case wRefBeam:
6096 if(itemid<0)
6097 return i;
6098
6099 if(!(shield.misc1 & shSWORD))
6100 return i;
6101
6102 reflect = ((shield.misc2 & shSWORD) != 0);
6103 break;
6104
6105 case wRefRock:
6106 if(itemid<0)
6107 return i;
6108
6109 if(!(shield.misc1 & shROCK))
6110 return i;
6111
6112 reflect = (shield.misc2 & shROCK);
6113 break;
6114
6115 default:
6116 return -1;
6117 }
6118
6119 2 bool allow_inactive = (shield.flags & ITEM_FLAG9);
6120
10/20
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
2 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6121 return i;
6122
6123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!hitshield)
6124 2 return i;
6125
6126 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6127
6128 paymagiccost(itemid);
6129
6130 lw->onhit(false, 1+reflect, dir);
6131 lw->ignoreHero=true;
6132 lw->ignorecombo=-1;
6133 sfx(shield.usesound,pan(x.getInt()));
6134 }
6135
6136 5649688 return -1;
6137 5755640 }
6138
6139 10103155 void HeroClass::checkhit()
6140 {
6141
2/2
✓ Branch 0 taken 3696654 times.
✓ Branch 1 taken 6406501 times.
10103155 if(checkhero==true)
6142 {
6143
2/2
✓ Branch 0 taken 6085872 times.
✓ Branch 1 taken 320629 times.
6406501 if(hclk>0)
6144 {
6145 320629 --hclk;
6146 320629 }
6147
6148
1/2
✓ Branch 0 taken 6406501 times.
✗ Branch 1 not taken.
6406501 if(DivineProtectionShieldClk>0)
6149 {
6150 --DivineProtectionShieldClk;
6151
6152 if(DivineProtectionShieldClk == 0 && div_prot_item != -1)
6153 {
6154 stop_sfx(itemsbuf[div_prot_item].usesound);
6155 stop_sfx(itemsbuf[div_prot_item].usesound+1);
6156 div_prot_item = -1;
6157 }
6158 else if(get_bit(quest_rules,qr_MORESOUNDS) && !(DivineProtectionShieldClk&0xF00) && div_prot_item != -1)
6159 {
6160 stop_sfx(itemsbuf[div_prot_item].usesound);
6161 cont_sfx(itemsbuf[div_prot_item].usesound+1);
6162 }
6163 }
6164 6406501 }
6165
6166
4/4
✓ Branch 0 taken 6345566 times.
✓ Branch 1 taken 3757589 times.
✓ Branch 2 taken 6341848 times.
✓ Branch 3 taken 3718 times.
10103155 if(hclk<39 && action==gothit)
6167 {
6168 3718 action=none; FFCore.setHeroAction(none);
6169 3718 }
6170
6171
5/6
✓ Branch 0 taken 6345566 times.
✓ Branch 1 taken 3757589 times.
✓ Branch 2 taken 6345514 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6345514 times.
10103155 if(hclk<39 && (action==swimhit || action == sideswimhit))
6172 {
6173 52 SetSwim();
6174 52 }
6175
6176
4/4
✓ Branch 0 taken 54187 times.
✓ Branch 1 taken 10048968 times.
✓ Branch 2 taken 14599 times.
✓ Branch 3 taken 39588 times.
10103155 if(hclk>=40 && action==gothit)
6177 {
6178 39588 int val = check_pitslide();
6179
4/4
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 39306 times.
✓ Branch 2 taken 39708 times.
✓ Branch 3 taken 39426 times.
39588 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6180 {
6181
2/2
✓ Branch 0 taken 158832 times.
✓ Branch 1 taken 39708 times.
198540 for(int32_t i=0; i<4; i++)
6182 {
6183
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 34572 times.
✓ Branch 2 taken 38344 times.
✓ Branch 3 taken 41012 times.
✓ Branch 4 taken 44904 times.
158832 switch(hitdir)
6184 {
6185 case up:
6186
6/6
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 32388 times.
✓ Branch 2 taken 30154 times.
✓ Branch 3 taken 2234 times.
✓ Branch 4 taken 2196 times.
✓ Branch 5 taken 32376 times.
34572 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6187 {
6188 2196 action=none; FFCore.setHeroAction(none);
6189 2196 }
6190
2/2
✓ Branch 0 taken 32372 times.
✓ Branch 1 taken 4 times.
32376 else if (val == -1) --y;
6191
6192 34572 break;
6193
6194 case down:
6195
6/6
✓ Branch 0 taken 3031 times.
✓ Branch 1 taken 35313 times.
✓ Branch 2 taken 2360 times.
✓ Branch 3 taken 32953 times.
✓ Branch 4 taken 3059 times.
✓ Branch 5 taken 35285 times.
38344 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6196 {
6197 3059 action=none; FFCore.setHeroAction(none);
6198 3059 }
6199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35285 times.
35285 else if (val == -1) ++y;
6200
6201 38344 break;
6202
6203 case left:
6204
7/8
✓ Branch 0 taken 39623 times.
✓ Branch 1 taken 1389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39623 times.
✓ Branch 4 taken 854 times.
✓ Branch 5 taken 38769 times.
✓ Branch 6 taken 1393 times.
✓ Branch 7 taken 39619 times.
41012 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6205 {
6206 1393 action=none; FFCore.setHeroAction(none);
6207 1393 }
6208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39619 times.
39619 else if (val == -1) --x;
6209
6210 41012 break;
6211
6212 case right:
6213
7/8
✓ Branch 0 taken 43202 times.
✓ Branch 1 taken 1702 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43202 times.
✓ Branch 4 taken 42593 times.
✓ Branch 5 taken 609 times.
✓ Branch 6 taken 1714 times.
✓ Branch 7 taken 43190 times.
44904 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6214 {
6215 1714 action=none; FFCore.setHeroAction(none);
6216 1714 }
6217
1/2
✓ Branch 0 taken 43190 times.
✗ Branch 1 not taken.
43190 else if (val == -1) ++x;
6218
6219 44904 break;
6220 }
6221 158832 }
6222 39708 }
6223 39828 }
6224
6225
18/20
✓ Branch 0 taken 6092437 times.
✓ Branch 1 taken 4010958 times.
✓ Branch 2 taken 6092238 times.
✓ Branch 3 taken 199 times.
✓ Branch 4 taken 6082538 times.
✓ Branch 5 taken 9700 times.
✓ Branch 6 taken 6081962 times.
✓ Branch 7 taken 576 times.
✓ Branch 8 taken 6081962 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6081962 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6081814 times.
✓ Branch 13 taken 148 times.
✓ Branch 14 taken 6077935 times.
✓ Branch 15 taken 3879 times.
✓ Branch 16 taken 4915 times.
✓ Branch 17 taken 6073020 times.
✓ Branch 18 taken 4329937 times.
✓ Branch 19 taken 4334852 times.
10103395 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6226 {
6227 8355397 return;
6228 }
6229
6230
2/2
✓ Branch 0 taken 6872557 times.
✓ Branch 1 taken 6072921 times.
12945478 for(int32_t i=0; i<Lwpns.Count(); i++)
6231 {
6232 6872557 sprite *s = Lwpns.spr(i);
6233 6872557 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6234 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6235 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6236
13/14
✓ Branch 0 taken 396935 times.
✓ Branch 1 taken 6475622 times.
✓ Branch 2 taken 2140770 times.
✓ Branch 3 taken 4334852 times.
✓ Branch 4 taken 2140770 times.
✓ Branch 5 taken 2194082 times.
✓ Branch 6 taken 2116595 times.
✓ Branch 7 taken 77487 times.
✓ Branch 8 taken 2116595 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 80797 times.
✓ Branch 11 taken 2035798 times.
✓ Branch 12 taken 40325 times.
✓ Branch 13 taken 41840 times.
6872557 if((!(itemid==-1&&get_bit(quest_rules,qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && (scriptcoldet&1) && !fallclk && (!superman || !get_bit(quest_rules,qr_FIREPROOFHERO2)))
6237 {
6238
9/10
✓ Branch 0 taken 2005679 times.
✓ Branch 1 taken 71959 times.
✓ Branch 2 taken 71610 times.
✓ Branch 3 taken 349 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 349 times.
✓ Branch 6 taken 360 times.
✓ Branch 7 taken 71250 times.
✓ Branch 8 taken 2076929 times.
✓ Branch 9 taken 25 times.
2077663 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6239
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
709 (itemid < 0 || itemsbuf[itemid].family!=itype_divinefire))
6240 {
6241 25 std::vector<int32_t> &ev = FFCore.eventData;
6242 25 ev.clear();
6243 25 ev.push_back(lwpn_dp(i)*10000);
6244 25 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6245 25 ev.push_back(0);
6246 25 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6247 25 ev.push_back(48*10000);
6248 25 ev.push_back(ZSD_LWPN*10000);
6249 25 ev.push_back(s->getUID());
6250 25 ev.push_back(ZSD_NONE*10000);
6251 25 ev.push_back(0);
6252
6253 25 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6254 25 int32_t dmg = ev[0]/10000;
6255 25 bool nullhit = ev[2] != 0;
6256
6257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(nullhit) {ev.clear(); return;}
6258
6259 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6260 25 ev[0] = ringpower(dmg)*10000;
6261
6262 25 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6263 25 dmg = ev[0]/10000;
6264 25 int32_t hdir = ev[1]/10000;
6265 25 nullhit = ev[2] != 0;
6266 25 bool divineprot = ev[3] != 0;
6267 25 int32_t iframes = ev[4] / 10000;
6268 25 ev.clear();
6269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(nullhit) return;
6270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!divineprot)
6271 {
6272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 game->set_life(zc_max(game->get_life()-dmg,0));
6273
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (!get_bit(quest_rules, qr_BROKENHITBY))
6274 {
6275 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6276 if (get_bit(quest_rules, qr_BROKENHITBY))
6277 {
6278 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6279 }
6280 else
6281 {
6282
6283 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getScriptUID());
6284 }
6285 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6286 sethitHeroUID(HIT_BY_LWEAPON_TYPE, ((weapon*)(Lwpns.spr(i)))->id);
6287 if (((weapon*)(Lwpns.spr(i)))->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, ((weapon*)(Lwpns.spr(i)))->parentitem);
6288 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6289 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[((weapon*)(Lwpns.spr(i)))->parentitem].family);
6290 }
6291 25 }
6292
6293 25 hitdir = hdir;
6294
6295
3/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
25 if (action != rafting && action != freeze && action != sideswimfreeze)
6296 {
6297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if (IsSideSwim())
6298 {
6299 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6300 }
6301
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 else if (action == swimming || hopclk == 0xFF)
6302 {
6303 action=swimhit; FFCore.setHeroAction(swimhit);
6304 }
6305 else
6306 {
6307 25 action=gothit; FFCore.setHeroAction(gothit);
6308 }
6309 25 }
6310
6311
5/8
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
25 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6312 {
6313 5 spins = charging = attackclk = 0;
6314 5 attack=none;
6315 5 tapping = false;
6316 5 }
6317
6318 25 hclk=iframes;
6319 25 sfx(getHurtSFX(),pan(x.getInt()));
6320 25 return;
6321 }
6322 2076929 }
6323
6324 // check enemy weapons true, 1, -1
6325 //
6326
2/2
✓ Branch 0 taken 2519899 times.
✓ Branch 1 taken 17781 times.
2591676 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6327 {
6328
6/6
✓ Branch 0 taken 1717 times.
✓ Branch 1 taken 16064 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 1558 times.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 100 times.
17781 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6329 {
6330
1/2
✓ Branch 0 taken 16164 times.
✗ Branch 1 not taken.
16164 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6331 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6332 16164 itemid = vbound(itemid, 0, MAXITEMS-1);
6333
6334
2/2
✓ Branch 0 taken 16160 times.
✓ Branch 1 taken 1039 times.
17199 for(int32_t j=0; j<Ewpns.Count(); j++)
6335 {
6336 1039 sprite *t = Ewpns.spr(j);
6337
6338
2/2
✓ Branch 0 taken 1035 times.
✓ Branch 1 taken 4 times.
1039 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6339 {
6340 4 bool reflect = false;
6341 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6342
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
4 switch(t->id)
6343 {
6344 case ewBrang:
6345 if(!(itemsbuf[itemid].misc3 & shBRANG)) break;
6346
6347 reflect = ((itemsbuf[itemid].misc4 & shBRANG) != 0);
6348 goto killweapon;
6349
6350 case ewArrow:
6351 if(!(itemsbuf[itemid].misc3 & shARROW)) break;
6352
6353 reflect = ((itemsbuf[itemid].misc4 & shARROW) != 0);
6354 goto killweapon;
6355
6356 case ewRock:
6357 if(!(itemsbuf[itemid].misc3 & shROCK)) break;
6358
6359 reflect = ((itemsbuf[itemid].misc4 & shROCK) != 0);
6360 goto killweapon;
6361
6362 case ewFireball2:
6363 case ewFireball:
6364 {
6365 int32_t mask = (((weapon*)t)->type&1 ? shFIREBALL2 : shFIREBALL);
6366
6367 if(!(itemsbuf[itemid].misc3 & mask)) break;
6368
6369 reflect = ((itemsbuf[itemid].misc4 & mask) != 0);
6370 goto killweapon;
6371 }
6372
6373 case ewSword:
6374 if(!(itemsbuf[itemid].misc3 & shSWORD)) break;
6375
6376 reflect = ((itemsbuf[itemid].misc4 & shSWORD) != 0);
6377 goto killweapon;
6378
6379 case wRefMagic:
6380 case ewMagic:
6381 if(!(itemsbuf[itemid].misc3 & shMAGIC)) break;
6382
6383 reflect = ((itemsbuf[itemid].misc4 & shMAGIC) != 0);
6384 goto killweapon;
6385
6386 case wScript1:
6387 case wScript2:
6388 case wScript3:
6389 case wScript4:
6390 case wScript5:
6391 case wScript6:
6392 case wScript7:
6393 case wScript8:
6394 case wScript9:
6395 case wScript10:
6396 if(!(itemsbuf[itemid].misc3 & shSCRIPT)) break;
6397
6398 reflect = ((itemsbuf[itemid].misc4 & shSCRIPT) != 0);
6399 goto killweapon;
6400
6401 case ewLitBomb:
6402 case ewLitSBomb:
6403 killweapon:
6404 ((weapon*)s)->dead=1;
6405 weapon *ew = ((weapon*)t);
6406 int32_t oldid = ew->id;
6407 ew->onhit(true, reflect ? 2 : 1, s->dir);
6408
6409 if(ew->id != oldid || (ew->id>=wScript1 && ew->id<=wScript10)) // changed type from ewX to wX... Except for script weapons
6410 {
6411 Lwpns.add(ew);
6412 Ewpns.remove(ew);
6413 ew->isLWeapon = true; //Make sure this gets set everywhere!
6414 }
6415
6416 if(ew->id==wRefMagic)
6417 {
6418 ew->ignoreHero=true;
6419 ew->ignorecombo=-1;
6420 }
6421
6422 break;
6423 }
6424
6425 4 break;
6426 }
6427 1035 }
6428 16164 }
6429 17781 }
6430
6431
6/6
✓ Branch 0 taken 1733114 times.
✓ Branch 1 taken 804566 times.
✓ Branch 2 taken 396935 times.
✓ Branch 3 taken 1336179 times.
✓ Branch 4 taken 32722 times.
✓ Branch 5 taken 364213 times.
2537680 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_bit(quest_rules,qr_OUCHBOMBS)))
6432 {
6433
6/8
✓ Branch 0 taken 830584 times.
✓ Branch 1 taken 6704 times.
✓ Branch 2 taken 6596 times.
✓ Branch 3 taken 830692 times.
✓ Branch 4 taken 6596 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6596 times.
837288 if(((s->id==wBomb)||(s->id==wSBomb)) && !superman && (scriptcoldet&1) && !fallclk)
6434 {
6435 6596 weapon* w = (weapon*)s;
6436 6596 bool didhit = s->hit(this);
6437
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 7 times.
6596 if(didhit)
6438 {
6439 7 std::vector<int32_t> &ev = FFCore.eventData;
6440 7 ev.clear();
6441
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 ev.push_back(((((weapon*)s)->parentitem>-1 ? itemsbuf[((weapon*)s)->parentitem].misc3 : ((weapon*)s)->power) *game->get_hp_per_heart())*10000);
6442 7 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6443 7 ev.push_back(0);
6444 7 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6445 7 ev.push_back(48*10000);
6446 7 ev.push_back(ZSD_LWPN*10000);
6447 7 ev.push_back(s->getUID());
6448 7 ev.push_back(ZSD_NONE*10000);
6449 7 ev.push_back(0);
6450
6451 7 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6452 7 int32_t dmg = ev[0]/10000;
6453 7 bool nullhit = ev[2] != 0;
6454
6455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(nullhit) {ev.clear(); return;}
6456
6457 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6458 7 ev[0] = ringpower(dmg)*10000;
6459
6460 7 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6461 7 dmg = ev[0]/10000;
6462 7 int32_t hdir = ev[1]/10000;
6463 7 nullhit = ev[2] != 0;
6464 7 bool divineprot = ev[3] != 0;
6465 7 int32_t iframes = ev[4] / 10000;
6466 7 ev.clear();
6467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(nullhit) return;
6468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(!divineprot)
6469 {
6470
3/6
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
7 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6471
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (!get_bit(quest_rules, qr_BROKENHITBY))
6472 {
6473 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6474 if (get_bit(quest_rules, qr_BROKENHITBY))
6475 {
6476 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6477 }
6478 else
6479 {
6480
6481 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getScriptUID());
6482 }
6483 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6484 sethitHeroUID(HIT_BY_LWEAPON_TYPE, ((weapon*)(Lwpns.spr(i)))->id);
6485 if (((weapon*)(Lwpns.spr(i)))->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, ((weapon*)(Lwpns.spr(i)))->parentitem);
6486 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6487 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[((weapon*)(Lwpns.spr(i)))->parentitem].family);
6488 }
6489 7 }
6490
6491 7 hitdir = hdir;
6492
6493
3/6
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
7 if (action != rafting && action != freeze && action != sideswimfreeze)
6494 {
6495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (IsSideSwim())
6496 {
6497 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6498 }
6499
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 else if (action == swimming || hopclk == 0xFF)
6500 {
6501 action=swimhit; FFCore.setHeroAction(swimhit);
6502 }
6503 else
6504 {
6505 7 action=gothit; FFCore.setHeroAction(gothit);
6506 }
6507 7 }
6508
6509
4/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7 times.
7 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6510 {
6511 spins = charging = attackclk = 0;
6512 attack=none;
6513 tapping = false;
6514 }
6515
6516 7 hclk=iframes;
6517 7 sfx(getHurtSFX(),pan(x.getInt()));
6518 7 return;
6519 }
6520 6589 }
6521 837281 }
6522
6523
7/8
✓ Branch 0 taken 2537673 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6234 times.
✓ Branch 3 taken 2531439 times.
✓ Branch 4 taken 6167 times.
✓ Branch 5 taken 67 times.
✓ Branch 6 taken 2537606 times.
✓ Branch 7 taken 67 times.
2537673 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6524 {
6525 67 std::vector<int32_t> &ev = FFCore.eventData;
6526 67 ev.clear();
6527 67 ev.push_back(0);
6528 67 ev.push_back(s->dir*10000);
6529 67 ev.push_back(0);
6530 67 ev.push_back(0);
6531 67 ev.push_back(ZSD_LWPN*10000);
6532 67 ev.push_back(s->getUID());
6533 67 ev.push_back(ZSD_NONE*10000);
6534 67 ev.push_back(0);
6535
6536 67 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6537 67 bool nullhit = ev[2] != 0;
6538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(nullhit) {ev.clear(); return;}
6539
6540 67 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6541 67 int32_t hdir = ev[1]/10000;
6542 67 nullhit = ev[2] != 0;
6543 67 ev.clear();
6544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(nullhit) return;
6545
6546 67 reset_hookshot();
6547 67 xofs=1000;
6548 67 action=inwind; FFCore.setHeroAction(inwind);
6549 67 dir=s->dir=hdir;
6550 67 spins = charging = attackclk = 0;
6551
6552 // In case Hero used two whistles in a row, summoning two whirlwinds,
6553 // check which whistle's whirlwind picked him up so the correct
6554 // warp ring will be used
6555 67 int32_t whistle=((weapon*)s)->parentitem;
6556
6557
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
67 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6558 67 whistleitem=whistle;
6559
6560 67 return;
6561 }
6562 2537606 }
6563
6564
6/8
✓ Branch 0 taken 6008922 times.
✓ Branch 1 taken 63999 times.
✓ Branch 2 taken 5904764 times.
✓ Branch 3 taken 104158 times.
✓ Branch 4 taken 5904764 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5904764 times.
11977685 if(action==rafting || action==freeze || action==sideswimfreeze ||
6565
4/8
✓ Branch 0 taken 5904764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5904764 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5904764 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5904764 times.
✗ Branch 7 not taken.
5904764 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6566 168157 return;
6567
6568 5904764 int32_t hit2 = -1;
6569 5904764 do
6570 {
6571
2/2
✓ Branch 0 taken 674007 times.
✓ Branch 1 taken 5236607 times.
5910614 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6572 5236607 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6573
6574
2/2
✓ Branch 0 taken 5897269 times.
✓ Branch 1 taken 13345 times.
5910614 if(hit2!=-1)
6575 {
6576
2/2
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 7495 times.
13345 if (hithero(hit2) == 0) return;
6577 5850 }
6578
2/2
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 5897269 times.
5903119 } while (hit2 != -1);
6579
6/6
✓ Branch 0 taken 5757543 times.
✓ Branch 1 taken 139726 times.
✓ Branch 2 taken 5756093 times.
✓ Branch 3 taken 1450 times.
✓ Branch 4 taken 453 times.
✓ Branch 5 taken 5755640 times.
5897269 if (superman || !(scriptcoldet&1) || fallclk) return;
6580 5755640 hit2 = LwpnHit();
6581
6582
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5755638 times.
5755640 if(hit2!=-1)
6583 {
6584 2 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6585 2 std::vector<int32_t> &ev = FFCore.eventData;
6586 2 ev.clear();
6587 2 ev.push_back((lwpn_dp(hit2)*10000));
6588 2 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6589 2 ev.push_back(0);
6590 2 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6591 2 ev.push_back(48*10000);
6592 2 ev.push_back(ZSD_LWPN*10000);
6593 2 ev.push_back(lwpnspr->getUID());
6594 2 ev.push_back(ZSD_NONE*10000);
6595 2 ev.push_back(0);
6596
6597 2 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6598 2 int32_t dmg = ev[0]/10000;
6599 2 bool nullhit = ev[2] != 0;
6600
6601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nullhit) {ev.clear(); return;}
6602
6603 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6604 2 ev[0] = ringpower(dmg)*10000;
6605
6606 2 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6607 2 dmg = ev[0]/10000;
6608 2 int32_t hdir = ev[1]/10000;
6609 2 nullhit = ev[2] != 0;
6610 2 bool divineprot = ev[3] != 0;
6611 2 int32_t iframes = ev[4] / 10000;
6612 2 ev.clear();
6613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nullhit) return;
6614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!divineprot)
6615 {
6616
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 game->set_life(zc_max(game->get_life()-dmg,0));
6617 2 sethitHeroUID(HIT_BY_LWEAPON,(hit2+1));
6618
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (get_bit(quest_rules, qr_BROKENHITBY))
6619 {
6620 2 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getUID());
6621 2 }
6622 else
6623 {
6624
6625 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getScriptUID());
6626 }
6627 2 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,lwpnspr->getUID());
6628 2 sethitHeroUID(HIT_BY_LWEAPON_TYPE, lwpnspr->id);
6629
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (lwpnspr->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, lwpnspr->parentitem);
6630 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6631 2 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[lwpnspr->parentitem].family);
6632 2 }
6633
6634 2 hitdir = hdir;
6635 2 lwpnspr->onhit(false);
6636
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (IsSideSwim())
6638 {
6639 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6640 }
6641
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 else if(action==swimming || hopclk==0xFF)
6642 {
6643 action=swimhit; FFCore.setHeroAction(swimhit);
6644 }
6645 else
6646 {
6647 2 action=gothit; FFCore.setHeroAction(gothit);
6648 }
6649
6650 2 hclk=iframes;
6651
6652
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
2 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6653 {
6654 spins = charging = attackclk = 0;
6655 attack=none;
6656 tapping = false;
6657 }
6658
6659 2 sfx(getHurtSFX(),pan(x.getInt()));
6660 2 return;
6661 }
6662
6663 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6664
6665 5755638 hit2 = EwpnHit();
6666
6667
2/2
✓ Branch 0 taken 2890 times.
✓ Branch 1 taken 5752748 times.
5755638 if(hit2!=-1)
6668 {
6669 2890 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6670 2890 std::vector<int32_t> &ev = FFCore.eventData;
6671 2890 ev.clear();
6672 2890 ev.push_back((ewpn_dp(hit2)*10000));
6673 2890 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6674 2890 ev.push_back(0);
6675 2890 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6676 2890 ev.push_back(48*10000);
6677 2890 ev.push_back(ZSD_EWPN*10000);
6678 2890 ev.push_back(ewpnspr->getUID());
6679 2890 ev.push_back(ZSD_NONE*10000);
6680 2890 ev.push_back(0);
6681
6682 2890 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6683 2890 int32_t dmg = ev[0]/10000;
6684 2890 bool nullhit = ev[2] != 0;
6685
6686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if(nullhit) {ev.clear(); return;}
6687
6688 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6689 2890 ev[0] = ringpower(dmg)*10000;
6690
6691 2890 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6692 2890 dmg = ev[0]/10000;
6693 2890 int32_t hdir = ev[1]/10000;
6694 2890 nullhit = ev[2] != 0;
6695 2890 bool divineprot = ev[3] != 0;
6696 2890 int32_t iframes = ev[4] / 10000;
6697 2890 ev.clear();
6698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if(nullhit) return;
6699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if(!divineprot)
6700 {
6701
2/2
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 19 times.
2890 game->set_life(zc_max(game->get_life()-dmg,0));
6702 2890 sethitHeroUID(HIT_BY_EWEAPON,(hit2+1));
6703
1/2
✓ Branch 0 taken 2890 times.
✗ Branch 1 not taken.
2890 if (get_bit(quest_rules, qr_BROKENHITBY))
6704 {
6705 2890 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getUID());
6706 2890 }
6707 else
6708 {
6709
6710 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getScriptUID());
6711 }
6712 2890 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID,ewpnspr->getUID());
6713 2890 sethitHeroUID(HIT_BY_EWEAPON_TYPE, ewpnspr->id);
6714 2890 }
6715
6716 2890 hitdir = hdir;
6717 2890 ewpnspr->onhit(false);
6718
6719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if (IsSideSwim())
6720 {
6721 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6722 }
6723
3/4
✓ Branch 0 taken 2861 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2861 times.
2890 else if(action==swimming || hopclk==0xFF)
6724 {
6725 29 action=swimhit; FFCore.setHeroAction(swimhit);
6726 29 }
6727 else
6728 {
6729 2861 action=gothit; FFCore.setHeroAction(gothit);
6730 }
6731
6732 2890 hclk=iframes;
6733
6734
7/8
✓ Branch 0 taken 2887 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2887 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1006 times.
✓ Branch 5 taken 1881 times.
✓ Branch 6 taken 53 times.
✓ Branch 7 taken 953 times.
2890 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6735 {
6736 1937 spins = charging = attackclk = 0;
6737 1937 attack=none;
6738 1937 tapping = false;
6739 1937 }
6740
6741 2890 sfx(getHurtSFX(),pan(x.getInt()));
6742 2890 return;
6743 }
6744
6745 // The rest of this method deals with damage combos, which can be jumped over.
6746
4/4
✓ Branch 0 taken 5748840 times.
✓ Branch 1 taken 3908 times.
✓ Branch 2 taken 5748840 times.
✓ Branch 3 taken 3908 times.
5752748 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
6747
6748 5748840 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
6749 5748840 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
6750
2/2
✓ Branch 0 taken 47666 times.
✓ Branch 1 taken 5701174 times.
5748840 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
6751
2/2
✓ Branch 0 taken 47666 times.
✓ Branch 1 taken 5701174 times.
5748840 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
6752
6753
2/2
✓ Branch 0 taken 5748840 times.
✓ Branch 1 taken 9666308 times.
15415148 for(int32_t i=get_bit(quest_rules, qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
6754 9666308 (void)checkdamagecombos(dx1,dx2,dy1,dy2,i);
6755 6406501 }
6756
6757 3549 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
6758 {
6759 3549 return checkdamagecombos(dx,dx,dy,dy);
6760 }
6761
6762 105 void HeroClass::doHit(int32_t hdir)
6763 {
6764 105 hitdir = hdir;
6765
6766
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 105 times.
105 if (action != rafting && action != freeze && action != sideswimfreeze)
6767 {
6768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (IsSideSwim())
6769 {
6770 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6771 }
6772
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
105 else if (action == swimming || hopclk == 0xFF)
6773 {
6774 action=swimhit; FFCore.setHeroAction(swimhit);
6775 }
6776 else
6777 {
6778 105 action=gothit; FFCore.setHeroAction(gothit);
6779 }
6780 105 }
6781
6782 105 hclk=48;
6783
6784
5/8
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✓ Branch 5 taken 39 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 66 times.
105 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6785 {
6786 39 spins = charging = attackclk = 0;
6787 39 attack=none;
6788 39 tapping = false;
6789 39 }
6790
6791 105 sfx(getHurtSFX(),pan(x.getInt()));
6792 105 }
6793
6794 10460803 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
6795 {
6796
5/6
✓ Branch 0 taken 10460790 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 10455904 times.
✓ Branch 3 taken 4886 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10455904 times.
10460803 if(hclk || superman || fallclk)
6797 4899 return false;
6798
6799 10455904 int32_t hp_mod[4] = {0};
6800 int32_t cid[8];
6801 10455904 byte hasKB = 0;
6802
6803 {
6804
2/2
✓ Branch 0 taken 4441434 times.
✓ Branch 1 taken 6014470 times.
10455904 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
6805 10455904 newcombo& cmb = combobuf[cid[0]];
6806
4/4
✓ Branch 0 taken 10455901 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10455757 times.
✓ Branch 3 taken 144 times.
10455904 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6807 {
6808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(cmb.usrflags&cflag1)
6809 hp_mod[0] = cmb.attributes[0] / -10000L;
6810 else
6811 144 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!(cmb.usrflags&cflag2))
6813 144 hasKB |= 1<<0;
6814 144 }
6815 }
6816 {
6817
2/2
✓ Branch 0 taken 4441434 times.
✓ Branch 1 taken 6014470 times.
10455904 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
6818 10455904 newcombo& cmb = combobuf[cid[1]];
6819
4/4
✓ Branch 0 taken 10455901 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10455740 times.
✓ Branch 3 taken 161 times.
10455904 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6820 {
6821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
161 if(cmb.usrflags&cflag1)
6822 hp_mod[1] = cmb.attributes[0] / -10000L;
6823 else
6824 161 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
161 if(!(cmb.usrflags&cflag2))
6826 161 hasKB |= 1<<1;
6827 161 }
6828 }
6829 {
6830
2/2
✓ Branch 0 taken 4441434 times.
✓ Branch 1 taken 6014470 times.
10455904 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
6831 10455904 newcombo& cmb = combobuf[cid[2]];
6832
4/4
✓ Branch 0 taken 10455901 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10455766 times.
✓ Branch 3 taken 135 times.
10455904 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6833 {
6834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if(cmb.usrflags&cflag1)
6835 hp_mod[2] = cmb.attributes[0] / -10000L;
6836 else
6837 135 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if(!(cmb.usrflags&cflag2))
6839 135 hasKB |= 1<<2;
6840 135 }
6841 }
6842 {
6843
2/2
✓ Branch 0 taken 4441434 times.
✓ Branch 1 taken 6014470 times.
10455904 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
6844 10455904 newcombo& cmb = combobuf[cid[3]];
6845
4/4
✓ Branch 0 taken 10455901 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10455751 times.
✓ Branch 3 taken 150 times.
10455904 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6846 {
6847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(cmb.usrflags&cflag1)
6848 hp_mod[3] = cmb.attributes[0] / -10000L;
6849 else
6850 150 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(!(cmb.usrflags&cflag2))
6852 150 hasKB |= 1<<3;
6853 150 }
6854 }
6855
6856 10455904 int32_t bestcid=0;
6857 10455904 int best_cpos = -1;
6858 10455904 int32_t hp_modtotal=0;
6859 10455904 int poses[8] = {COMBOPOS(dx1,dy1),COMBOPOS(dx1,dy2),COMBOPOS(dx2,dy1),COMBOPOS(dx2,dy2)};
6860
2/2
✓ Branch 0 taken 7628826 times.
✓ Branch 1 taken 2827078 times.
10455904 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6861
2/2
✓ Branch 0 taken 7623831 times.
✓ Branch 1 taken 2832073 times.
10455904 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6862
2/2
✓ Branch 0 taken 7628858 times.
✓ Branch 1 taken 2827046 times.
10455904 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6863
2/2
✓ Branch 0 taken 7623864 times.
✓ Branch 1 taken 2832040 times.
10455904 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6864
6865
2/2
✓ Branch 0 taken 20911808 times.
✓ Branch 1 taken 10455904 times.
31367712 for (int32_t i = 0; i <= 1; ++i)
6866 {
6867
2/2
✓ Branch 0 taken 15533581 times.
✓ Branch 1 taken 5378227 times.
20911808 if(tmpscr2[i].valid!=0)
6868 {
6869
2/2
✓ Branch 0 taken 5024615 times.
✓ Branch 1 taken 353612 times.
5378227 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
6870 {
6871
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6872
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6874
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6875 5024615 }
6876 else
6877 {
6878
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6879
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6880
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6881
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6882 }
6883 5378227 }
6884 20911808 }
6885
6886
2/2
✓ Branch 0 taken 41823616 times.
✓ Branch 1 taken 10455904 times.
52279520 for(int32_t i=0; i<4; i++)
6887 {
6888
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 26299224 times.
41823616 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
6889 {
6890
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
6891 {
6892
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotal)
6893 {
6894 63 hp_modtotal = hp_mod[i];
6895 63 bestcid = cid[i];
6896 63 best_cpos = poses[i];
6897 63 }
6898 15524232 }
6899
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
6900 {
6901
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotal)
6902 {
6903 hp_modtotal = hp_mod[i];
6904 bestcid = cid[i];
6905 best_cpos = poses[i];
6906 }
6907 139 }
6908 15524392 }
6909
2/2
✓ Branch 0 taken 26299107 times.
✓ Branch 1 taken 117 times.
26299224 else if(hp_mod[i] < hp_modtotal)
6910 {
6911 117 hp_modtotal = hp_mod[i];
6912 117 bestcid = cid[i];
6913 117 best_cpos = poses[i];
6914 117 }
6915 41823616 }
6916
6917 {
6918 10455904 poses[4] = getFFCAt(dx1,dy1);
6919
2/2
✓ Branch 0 taken 70167 times.
✓ Branch 1 taken 10385737 times.
10455904 cid[4] = poses[4] > -1 ? tmpscr->ffcs[poses[4]].getData() : 0;
6920 10455904 newcombo& cmb = combobuf[cid[4]];
6921
3/4
✓ Branch 0 taken 10455709 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 10455709 times.
✗ Branch 3 not taken.
10455904 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6922 {
6923 if(cmb.usrflags&cflag1 )
6924 hp_mod[0] = cmb.attributes[0]/10000L;
6925 else
6926 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6927 if(!(cmb.usrflags&cflag2))
6928 hasKB |= 1<<4;
6929 }
6930 }
6931 {
6932 10455904 poses[5] = getFFCAt(dx1,dy2);
6933
2/2
✓ Branch 0 taken 70514 times.
✓ Branch 1 taken 10385390 times.
10455904 cid[5] = poses[5] > -1 ? tmpscr->ffcs[poses[5]].getData() : 0;
6934 10455904 newcombo& cmb = combobuf[cid[5]];
6935
3/4
✓ Branch 0 taken 10455700 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 10455700 times.
✗ Branch 3 not taken.
10455904 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6936 {
6937 if(cmb.usrflags&cflag1 )
6938 hp_mod[1] = cmb.attributes[0]/10000L;
6939 else
6940 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6941 if(!(cmb.usrflags&cflag2))
6942 hasKB |= 1<<5;
6943 }
6944 }
6945 {
6946 10455904 poses[6] = getFFCAt(dx2,dy1);
6947
2/2
✓ Branch 0 taken 68302 times.
✓ Branch 1 taken 10387602 times.
10455904 cid[6] = poses[6] > -1 ? tmpscr->ffcs[poses[6]].getData() : 0;
6948 10455904 newcombo& cmb = combobuf[cid[6]];
6949
3/4
✓ Branch 0 taken 10455712 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 10455712 times.
✗ Branch 3 not taken.
10455904 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6950 {
6951 if(cmb.usrflags&cflag1 )
6952 hp_mod[2] = cmb.attributes[0]/10000L;
6953 else
6954 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6955 if(!(cmb.usrflags&cflag2))
6956 hasKB |= 1<<6;
6957 }
6958 }
6959 {
6960 10455904 poses[7] = getFFCAt(dx2,dy2);
6961
2/2
✓ Branch 0 taken 68686 times.
✓ Branch 1 taken 10387218 times.
10455904 cid[7] = poses[7] > -1 ? tmpscr->ffcs[poses[7]].getData() : 0;
6962 10455904 newcombo& cmb = combobuf[cid[7]];
6963
3/4
✓ Branch 0 taken 10455703 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 10455703 times.
✗ Branch 3 not taken.
10455904 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6964 {
6965 if(cmb.usrflags&cflag1 )
6966 hp_mod[3] = cmb.attributes[0]/10000L;
6967 else
6968 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6969 if(!(cmb.usrflags&cflag2))
6970 hasKB |= 1<<7;
6971 }
6972 }
6973
6974 10455904 int32_t bestffccid = 0;
6975 10455904 int best_ffcpos = -1;
6976 10455904 int32_t hp_modtotalffc = 0;
6977
6978
2/2
✓ Branch 0 taken 20911808 times.
✓ Branch 1 taken 10455904 times.
31367712 for (int32_t i = 0; i <= 1; ++i)
6979 {
6980
2/2
✓ Branch 0 taken 15533581 times.
✓ Branch 1 taken 5378227 times.
20911808 if(tmpscr2[i].valid!=0)
6981 {
6982
2/2
✓ Branch 0 taken 5024615 times.
✓ Branch 1 taken 353612 times.
5378227 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
6983 {
6984
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
6985
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
6986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
6987
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
6988 5024615 }
6989 else
6990 {
6991
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
6992
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
6993
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
6994
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
6995 }
6996 5378227 }
6997 20911808 }
6998
6999
2/2
✓ Branch 0 taken 41823616 times.
✓ Branch 1 taken 10455904 times.
52279520 for(int32_t i=0; i<4; i++)
7000 {
7001
2/2
✓ Branch 0 taken 277669 times.
✓ Branch 1 taken 41545947 times.
41823616 if(poses[i+4] < 0) continue;
7002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277669 times.
277669 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7003 {
7004 if(hp_modtotalffc >= 0)
7005 {
7006 if(hp_mod[i] < hp_modtotalffc)
7007 {
7008 hp_modtotalffc = hp_mod[i];
7009 bestffccid = cid[4+i];
7010 best_ffcpos = poses[4+i];
7011 }
7012 }
7013 else if(hp_mod[i] < 0)
7014 {
7015 if(hp_mod[i] > hp_modtotalffc)
7016 {
7017 hp_modtotalffc = hp_mod[i];
7018 bestffccid = cid[4+i];
7019 best_ffcpos = poses[4+i];
7020 }
7021 }
7022 }
7023
2/2
✓ Branch 0 taken 277664 times.
✓ Branch 1 taken 5 times.
277669 else if(hp_mod[i] < hp_modtotalffc)
7024 {
7025 5 hp_modtotalffc = hp_mod[i];
7026 5 bestffccid = cid[4+i];
7027 5 best_ffcpos = poses[4+i];
7028 5 }
7029 277669 }
7030
7031
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 10455729 times.
10455904 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7032 10455904 int best_type = 0;
7033
1/2
✓ Branch 0 taken 10455904 times.
✗ Branch 1 not taken.
10455904 if(hp_modtotalffc < hp_modtotal)
7034 {
7035 bestcid = bestffccid;
7036 best_type = 1;
7037 }
7038
7039 10455904 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7040 10455904 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7041 10455904 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7042
1/2
✓ Branch 0 taken 10455904 times.
✗ Branch 1 not taken.
10455904 if(current_ring)
7043 {
7044 global_defring = !global_defring;
7045 global_perilring = !global_perilring;
7046 }
7047 10455904 int32_t itemid = current_item_id(itype_boots);
7048
7049
2/2
✓ Branch 0 taken 10076929 times.
✓ Branch 1 taken 378975 times.
10455904 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7050
2/2
✓ Branch 0 taken 10076929 times.
✓ Branch 1 taken 378975 times.
10455904 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7051
7052
2/2
✓ Branch 0 taken 10455724 times.
✓ Branch 1 taken 180 times.
10455904 if(hp_modmin<0)
7053 {
7054
8/14
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 67 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 67 times.
✓ Branch 10 taken 67 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 67 times.
180 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7055 {
7056
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 8 times.
113 if (!do_health_check) return true;
7057 105 std::vector<int32_t> &ev = FFCore.eventData;
7058 105 ev.clear();
7059 105 ev.push_back(-hp_modmin*10000);
7060
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 ev.push_back((hasKB ? dir^1 : -1)*10000);
7061 105 ev.push_back(0);
7062 105 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7063 105 ev.push_back(48*10000);
7064 105 ev.push_back(ZSD_COMBODATA*10000);
7065 105 ev.push_back(bestcid);
7066 105 ev.push_back((best_type ? ZSD_FFC : ZSD_COMBOPOS)*10000);
7067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ev.push_back(best_type ? best_ffcpos : best_cpos*10000);
7068
7069 105 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7070 105 int32_t dmg = ev[0]/10000;
7071 105 bool nullhit = ev[2] != 0;
7072
7073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(nullhit) {ev.clear(); return false;}
7074
7075 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7076 105 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7077
7078 105 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7079 105 dmg = ev[0]/10000;
7080 105 int32_t hdir = ev[1]/10000;
7081 105 nullhit = ev[2] != 0;
7082 105 bool divineprot = ev[3] != 0;
7083 105 int32_t iframes = ev[4] / 10000;
7084 105 ev.clear();
7085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(nullhit) return false;
7086
7087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!divineprot)
7088 {
7089
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 game->set_life(zc_max(game->get_life()-dmg,0));
7090 105 }
7091
7092 105 hitdir = hdir;
7093 105 doHit(hitdir);
7094 105 hclk = iframes;
7095 105 return true;
7096 }
7097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7098 67 }
7099
7100 10455791 return false;
7101 10460803 }
7102
7103 13426 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7104 {
7105
1/2
✓ Branch 0 taken 13426 times.
✗ Branch 1 not taken.
13426 if(force_hdir > 3) force_hdir = -1;
7106 13426 enemy* enemyptr = (enemy*)guys.spr(hit2);
7107
1/2
✓ Branch 0 taken 13426 times.
✗ Branch 1 not taken.
13426 if(!enemyptr) return 0;
7108 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7109 13426 int32_t stompid = current_item_id(itype_stompboots);
7110
5/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13411 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
13426 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7111
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7112
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7113 {
7114 paymagiccost(stompid);
7115 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7116
7117 if(itemsbuf[stompid].flags & ITEM_FLAG1)
7118 {
7119 fall = -(itemsbuf[stompid].misc1);
7120 }
7121
7122 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7123 game->set_item(stompid,false);
7124
7125 // Stomp Boots script
7126 if(itemsbuf[stompid].script != 0 && !(FFCore.doscript(ScriptType::Item, stompid) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
7127 {
7128 int i = stompid;
7129 FFCore.reset_script_engine_data(ScriptType::Item, i);
7130 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[stompid].script, i);
7131 FFCore.deallocateAllArrays(ScriptType::Item, i);
7132 }
7133
7134 return -1;
7135 }
7136
5/6
✓ Branch 0 taken 9667 times.
✓ Branch 1 taken 3759 times.
✓ Branch 2 taken 9665 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9665 times.
13426 else if(superman || !(scriptcoldet&1) || fallclk)
7137 3761 return 0;
7138 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7139 //!Add a flag check to this if:
7140
5/6
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 5633 times.
✓ Branch 2 taken 4032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1830 times.
✓ Branch 5 taken 2202 times.
9665 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7141
3/4
✓ Branch 0 taken 1587 times.
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3789 times.
4032 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7142 {
7143 5876 return -1;
7144 }
7145
7146 3789 std::vector<int32_t> &ev = FFCore.eventData;
7147 3789 ev.clear();
7148 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7149 3789 ev.push_back((enemy_dp(hit2) *10000));
7150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3789 times.
3789 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7151 3789 ev.push_back(0);
7152 3789 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7153 3789 ev.push_back(48*10000);
7154 3789 ev.push_back(ZSD_NPC*10000);
7155 3789 ev.push_back(enemyptr->getUID());
7156 3789 ev.push_back(ZSD_NONE*10000);
7157 3789 ev.push_back(0);
7158
7159 3789 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7160 3789 int32_t dmg = ev[0] / 10000;
7161 3789 bool nullhit = ev[2] != 0;
7162
7163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3789 times.
3789 if(nullhit) {ev.clear(); return -1;}
7164
7165 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7166 3789 ev[0] = ((ringpower(dmg)*10000));
7167
7168 3789 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7169 3789 dmg = ev[0] / 10000;
7170 3789 int32_t hdir = ev[1] / 10000;
7171 3789 nullhit = ev[2] != 0;
7172 3789 bool divineprot = ev[3] != 0;
7173 3789 int32_t iframes = ev[4] / 10000;
7174 3789 ev.clear();
7175
7176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3789 times.
3789 if(nullhit) return -1;
7177
7178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3789 times.
3789 if(!divineprot)
7179 {
7180
2/2
✓ Branch 0 taken 3765 times.
✓ Branch 1 taken 24 times.
3789 game->set_life(zc_max(game->get_life()-dmg,0));
7181 3789 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7182 3789 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7183
1/2
✓ Branch 0 taken 3789 times.
✗ Branch 1 not taken.
3789 if (get_bit(quest_rules, qr_BROKENHITBY))
7184 {
7185 3789 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7186 3789 }
7187 else
7188 {
7189 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->script_UID);
7190 }
7191 3789 sethitHeroUID(HIT_BY_NPC_ENGINE_UID,enemyptr->getUID());
7192 3789 sethitHeroUID(HIT_BY_NPC_ID, enemyptr->id);
7193 3789 sethitHeroUID(HIT_BY_NPC_TYPE, enemyptr->family);
7194 3789 }
7195
7196 3789 hitdir = hdir;
7197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3789 times.
3789 if (IsSideSwim())
7198 {
7199 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7200 }
7201
3/4
✓ Branch 0 taken 3757 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3757 times.
3789 else if(action==swimming || hopclk==0xFF)
7202 {
7203 32 action=swimhit; FFCore.setHeroAction(swimhit);
7204 32 }
7205 else
7206 {
7207 3757 action=gothit; FFCore.setHeroAction(gothit);
7208 }
7209
7210 3789 hclk=iframes;
7211 3789 sfx(getHurtSFX(),pan(x.getInt()));
7212
7213
7/8
✓ Branch 0 taken 3787 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1557 times.
✓ Branch 5 taken 2230 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1509 times.
3789 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7214 {
7215 2280 spins = charging = attackclk = 0;
7216 2280 attack=none;
7217 2280 tapping = false;
7218 2280 }
7219
7220 3789 enemy_scored(hit2);
7221 3789 int32_t dm7 = enemyptr->dmisc7;
7222 3789 int32_t dm8 = enemyptr->dmisc8;
7223
7224
3/3
✓ Branch 0 taken 1737 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2049 times.
3789 switch(enemyptr->family)
7225 {
7226 case eeWALLM:
7227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(enemyptr->hp>0)
7228 {
7229 3 GrabHero(hit2);
7230 3 inwallm=true;
7231 3 action=none; FFCore.setHeroAction(none);
7232 3 }
7233 3 break;
7234
7235 //case eBUBBLEST:
7236 //case eeBUBBLE:
7237 case eeWALK:
7238 {
7239 2049 int32_t itemid = current_item_id(itype_whispring);
7240 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7241
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1889 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
2049 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7242
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1889 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
2049 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7243
7244
5/7
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 79 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
2049 switch(dm7)
7245 {
7246 case e7tTEMPJINX:
7247
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 258 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
277 if(dm8==0 || dm8==2)
7248
4/4
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 254 times.
512 if(swordclk>=0 && !(sworddivisor==0))
7249 254 swordclk=150;
7250
7251
3/4
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 258 times.
277 if(dm8==1 || dm8==2)
7252
3/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 18 times.
37 if(itemclk>=0 && !(itemdivisor==0))
7253 18 itemclk=150;
7254
7255 277 break;
7256
7257 case e7tPERMJINX:
7258
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
54 if(dm8==0 || dm8==2)
7259
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
38 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7260
7261
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
54 if(dm8==1 || dm8==2)
7262
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
16 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7263
7264 54 break;
7265
7266 case e7tUNJINX:
7267
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
79 if(dm8==0 || dm8==2)
7268 67 swordclk=0;
7269
7270
3/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
79 if(dm8==1 || dm8==2)
7271 12 itemclk=0;
7272
7273 79 break;
7274
7275 case e7tTAKEMAGIC:
7276 game->change_dmagic(-dm8*game->get_magicdrainrate());
7277 break;
7278
7279 case e7tTAKERUPEES:
7280 21 game->change_drupy(-dm8);
7281 21 break;
7282
7283 case e7tDRUNK:
7284 drunkclk += dm8;
7285 break;
7286 }
7287 2049 verifyAWpn();
7288
2/2
✓ Branch 0 taken 1998 times.
✓ Branch 1 taken 51 times.
2049 if(dm7 >= e7tEATITEMS)
7289 {
7290 51 EatHero(hit2);
7291 51 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7292 51 action=none; FFCore.setHeroAction(none);
7293 51 }
7294 }
7295 2049 }
7296 3789 return 0;
7297 13426 }
7298
7299 314009 void HeroClass::addsparkle(int32_t wpn)
7300 {
7301 //return;
7302 314009 weapon *w = (weapon*)Lwpns.spr(wpn);
7303 314009 int32_t itemid = w->parentitem;
7304
7305
2/2
✓ Branch 0 taken 310655 times.
✓ Branch 1 taken 3354 times.
314009 if(itemid<0)
7306 3354 return;
7307
7308 310655 int32_t itemtype = itemsbuf[itemid].family;
7309
7310
4/4
✓ Branch 0 taken 310582 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 77634 times.
✓ Branch 3 taken 232948 times.
310655 if(itemtype!=itype_cbyrna && frame%4)
7311 232948 return;
7312
7313
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 77634 times.
77707 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7314
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 77634 times.
77707 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7315 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7316
5/8
✓ Branch 0 taken 22591 times.
✓ Branch 1 taken 55116 times.
✓ Branch 2 taken 38407 times.
✓ Branch 3 taken 16709 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22591 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
77707 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7317 77707 int32_t direction=w->dir;
7318
7319
2/2
✓ Branch 0 taken 38407 times.
✓ Branch 1 taken 39300 times.
77707 if(sparkle_type)
7320 {
7321 39300 int32_t h=0;
7322 39300 int32_t v=0;
7323
7324
6/6
✓ Branch 0 taken 31465 times.
✓ Branch 1 taken 7835 times.
✓ Branch 2 taken 28007 times.
✓ Branch 3 taken 3458 times.
✓ Branch 4 taken 6095 times.
✓ Branch 5 taken 21912 times.
39300 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7325 {
7326 17388 h=-1;
7327 17388 }
7328
7329
6/6
✓ Branch 0 taken 31738 times.
✓ Branch 1 taken 7562 times.
✓ Branch 2 taken 26489 times.
✓ Branch 3 taken 5249 times.
✓ Branch 4 taken 3934 times.
✓ Branch 5 taken 22555 times.
39300 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7330 {
7331 16745 h=1;
7332 16745 }
7333
7334
6/6
✓ Branch 0 taken 37062 times.
✓ Branch 1 taken 2238 times.
✓ Branch 2 taken 33128 times.
✓ Branch 3 taken 3934 times.
✓ Branch 4 taken 6095 times.
✓ Branch 5 taken 27033 times.
39300 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7335 {
7336 12267 v=-1;
7337 12267 }
7338
7339
6/6
✓ Branch 0 taken 36371 times.
✓ Branch 1 taken 2929 times.
✓ Branch 2 taken 31122 times.
✓ Branch 3 taken 5249 times.
✓ Branch 4 taken 3458 times.
✓ Branch 5 taken 27664 times.
39300 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7340 {
7341 11636 v=1;
7342 11636 }
7343
7344 // Damaging boomerang sparkle?
7345
3/4
✓ Branch 0 taken 16709 times.
✓ Branch 1 taken 22591 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16709 times.
39300 if(wpn3 && itemtype==itype_brang)
7346 {
7347 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7348 // whatever it just bounced off of if it's shielded from that direction.
7349
6/6
✓ Branch 0 taken 10964 times.
✓ Branch 1 taken 5745 times.
✓ Branch 2 taken 10517 times.
✓ Branch 3 taken 447 times.
✓ Branch 4 taken 4476 times.
✓ Branch 5 taken 6041 times.
16709 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7350 6041 direction=oppositeDir[direction];
7351 16709 }
7352
4/4
✓ Branch 0 taken 38355 times.
✓ Branch 1 taken 945 times.
✓ Branch 2 taken 17684 times.
✓ Branch 3 taken 20671 times.
39300 if(itemtype==itype_brang && get_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7353
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 39227 times.
39300 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7354
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 39227 times.
39300 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7355
5/10
✓ Branch 0 taken 39300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39300 times.
✗ Branch 9 not taken.
39300 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7356 39300 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7357 39300 }
7358 314009 }
7359
7360 // For wPhantoms
7361 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7362 {
7363 if(frame%4) return;
7364
7365 int32_t arrow = -1;
7366
7367 for(int32_t i=0; i<Lwpns.Count(); i++)
7368 {
7369 weapon *w = (weapon*)Lwpns.spr(i);
7370
7371 if(w->id == wPhantom && w->type == type1)
7372 {
7373 arrow = i;
7374 break;
7375 }
7376 }
7377
7378 if(arrow==-1)
7379 {
7380 return;
7381 }
7382
7383 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7384 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7385 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7386 }
7387
7388 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7389 6406142 void HeroClass::PhantomsCleanup()
7390 {
7391
1/2
✓ Branch 0 taken 6406142 times.
✗ Branch 1 not taken.
6406142 if(Lwpns.idCount(wPhantom))
7392 {
7393 for(int32_t i=0; i<Lwpns.Count(); i++)
7394 {
7395 weapon *w = ((weapon *)Lwpns.spr(i));
7396 if ( w->id == wPhantom && !w->isScriptGenerated() )
7397 {
7398 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7399 {
7400 Lwpns.remove(w);
7401 }
7402 }
7403 }
7404 }
7405 6406142 }
7406
7407 //Waitframe handler for refilling operations
7408 4932 static void do_refill_waitframe()
7409 {
7410 4932 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7411
1/2
✓ Branch 0 taken 4932 times.
✗ Branch 1 not taken.
4932 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7412 {
7413 script_drawing_commands.Clear();
7414 if(DMaps[currdmap].passive_sub_script != 0)
7415 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
7416
7417 if (FFCore.waitdraw(ScriptType::PassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::PassiveSubscreen))
7418 {
7419 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
7420 FFCore.waitdraw(ScriptType::PassiveSubscreen) = false;
7421 }
7422 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7423 }
7424 4932 advanceframe(true);
7425 4932 }
7426 //Special handler if it's a "fairy revive"
7427 static void do_death_refill_waitframe()
7428 {
7429 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7430 //This script should be able to draw a 'fairy saving the player' animation -Em
7431 do_refill_waitframe();
7432 }
7433
7434 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7435 {
7436 int32_t found_unowned = -1;
7437 for(int q = 0; q < MAXITEMS; ++q)
7438 {
7439 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7440 {
7441 if(game->get_item(q))
7442 return q;
7443 if(unowned)
7444 found_unowned = q;
7445 }
7446 }
7447 return found_unowned;
7448 }
7449
7450 int32_t getPushDir(int32_t flag)
7451 {
7452 switch(flag)
7453 {
7454 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7455 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7456 case mfPUSHUINS:
7457 return up;
7458 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7459 return down;
7460 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7461 case mfPUSHLRINS: case mfPUSHLINS:
7462 return left;
7463 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7464 return right;
7465 }
7466 return -1;
7467 }
7468
7469 void post_item_collect();
7470
7471 6406502 bool HeroClass::handle_portal_collide(portal* p)
7472 {
7473
1/2
✓ Branch 0 taken 6406502 times.
✗ Branch 1 not taken.
6406502 if(!p) return false;
7474 6406502 p->animate(0);
7475
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6406502 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6406502 if(p->destdmap < 0 || p->destdmap >= MAXDMAPS)
7476 6406502 return false;
7477 if(abs(x - p->x) < 12
7478 && abs(y - p->y) < 12)
7479 {
7480 if(p->prox_active)
7481 {
7482 //Store some values to restore if 'warp fails'
7483 int32_t tLastEntrance = lastentrance,
7484 tLastEntranceDMap = lastentrance_dmap,
7485 tContScr = game->get_continue_scrn(),
7486 tContDMap = game->get_continue_dmap();
7487 int32_t sourcescr = currscr, sourcedmap = currdmap;
7488 zfix tx = x, ty = y, tz = z;
7489 x = p->x;
7490 y = p->y;
7491
7492 int32_t weff = p->weffect,
7493 wsfx = p->wsfx;
7494
7495 int32_t savep = p->saved_data;
7496 //After this line, 'p' becomes INVALID!
7497 FFCore.warp_player(wtIWARP, p->destdmap, p->destscr,
7498 -1, -1, weff, wsfx, 0, -1);
7499
7500 if(mirrorBonk()) //Invalid landing, warp back!
7501 {
7502 action = none; FFCore.setHeroAction(none);
7503 lastentrance = tLastEntrance;
7504 lastentrance_dmap = tLastEntranceDMap;
7505 game->set_continue_scrn(tContScr);
7506 game->set_continue_dmap(tContDMap);
7507 x = tx;
7508 y = ty;
7509 z = tz;
7510 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7511 wsfx, 0, -1);
7512 handle_portal_prox(&mirror_portal);
7513 portals.forEach([&](sprite& p)
7514 {
7515 handle_portal_prox((portal*)&p);
7516 return false;
7517 });
7518 }
7519 else game->clear_portal(savep); //Remove portal once used
7520 return true;
7521 }
7522 }
7523 else p->prox_active = true;
7524 return false;
7525 6406502 }
7526 16 void HeroClass::handle_portal_prox(portal* p)
7527 {
7528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p) return;
7529
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 p->prox_active = !(abs(x - p->x) < 12 && abs(y - p->y) < 12);
7530 16 }
7531 // returns true when game over
7532 18694755 bool HeroClass::animate(int32_t)
7533 {
7534 18694755 int32_t lsave=0;
7535
1/2
✓ Branch 0 taken 18694755 times.
✗ Branch 1 not taken.
18694755 if(immortal > 0)
7536 --immortal;
7537 18694755 prompt_combo = 0;
7538
2/2
✓ Branch 0 taken 12288253 times.
✓ Branch 1 taken 6406502 times.
18694755 if (onpassivedmg)
7539 {
7540 12288253 onpassivedmg=false;
7541 12288253 }
7542
1/2
✓ Branch 0 taken 6406502 times.
✗ Branch 1 not taken.
6406502 else if (damageovertimeclk)
7543 {
7544 damageovertimeclk = 0;
7545 }
7546
7547
2/2
✓ Branch 0 taken 18693662 times.
✓ Branch 1 taken 1093 times.
18694755 if(lift_wpn)
7548 {
7549 1093 auto oldid = lift_wpn->id;
7550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1093 times.
1093 switch(lift_wpn->id)
7551 {
7552 case wLitBomb:
7553 case wBomb:
7554 case wLitSBomb:
7555 case wSBomb:
7556 if(lift_wpn->misc && get_bit(quest_rules,qr_HELD_BOMBS_EXPLODE)) //timed fuse
7557 {
7558 lift_wpn->limited_animate();
7559 if(lift_wpn->id != oldid)
7560 {
7561 lift_wpn->moveflags &= ~FLAG_OBEYS_GRAV;
7562 drop_liftwpn();
7563 goto heroanimate_skip_liftwpn;
7564 }
7565 ++lift_wpn->clk;
7566 }
7567 break;
7568 }
7569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1093 times.
1093 if(lift_wpn->dead>0)
7570 --lift_wpn->dead;
7571
7572
1/2
✓ Branch 0 taken 1093 times.
✗ Branch 1 not taken.
1093 if(lift_wpn->dead==0)
7573 {
7574 if(lift_wpn->death_spawnitem > -1)
7575 {
7576 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, lift_wpn->death_spawnitem, lift_wpn->death_item_pflags, 0));
7577 itm->fakez = lift_wpn->fakez;
7578 items.add(itm);
7579 }
7580 if(lift_wpn->death_spawndropset > -1)
7581 {
7582 auto itid = select_dropitem(lift_wpn->death_spawndropset);
7583 if(itid > -1)
7584 {
7585 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, itid, lift_wpn->death_item_pflags, 0));
7586 itm->fakez = lift_wpn->fakez;
7587 itm->from_dropset = lift_wpn->death_spawndropset;
7588 items.add(itm);
7589 }
7590 }
7591 switch(lift_wpn->death_sprite)
7592 {
7593 case -2: decorations.add(new dBushLeaves(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dBUSHLEAVES, 0, 0)); break;
7594 case -3: decorations.add(new dFlowerClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dFLOWERCLIPPINGS, 0, 0)); break;
7595 case -4: decorations.add(new dGrassClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dGRASSCLIPPINGS, 0, 0)); break;
7596 default:
7597 if(lift_wpn->death_sprite < 0) break;
7598 decorations.add(new comboSprite(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), 0, 0, lift_wpn->death_sprite));
7599 }
7600 if(lift_wpn->death_sfx > 0)
7601 sfx(lift_wpn->death_sfx, pan(int32_t(lift_wpn->x)));
7602 delete lift_wpn;
7603 lift_wpn = nullptr;
7604 }
7605 heroanimate_skip_liftwpn:;
7606 1093 }
7607
7608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18694755 times.
18694755 if(cheats_execute_goto)
7609 {
7610 didpit=true;
7611 pitx=x;
7612 pity=y;
7613 dowarp(3,0);
7614 cheats_execute_goto=false;
7615 solid_update(false);
7616 return false;
7617 }
7618
7619
1/2
✓ Branch 0 taken 18694755 times.
✗ Branch 1 not taken.
18694755 if(cheats_execute_light)
7620 {
7621 naturaldark = !naturaldark;
7622 lighting(false, false, pal_litOVERRIDE);//Forcibly set permLit, overriding it's current setting
7623 cheats_execute_light = false;
7624 }
7625
7626
3/4
✓ Branch 0 taken 6406502 times.
✓ Branch 1 taken 12288253 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6406502 times.
18694755 if(action!=climbcovertop&&action!=climbcoverbottom)
7627 {
7628 6406502 climb_cover_x=-1000;
7629 6406502 climb_cover_y=-1000;
7630 6406502 }
7631
7632 18694755 handle_portal_collide(&mirror_portal);
7633
1/2
✓ Branch 0 taken 18694755 times.
✗ Branch 1 not taken.
18694755 portals.forEach([&](sprite& p)
7634 {
7635 return handle_portal_collide((portal*)&p);
7636 });
7637
7638
3/4
✓ Branch 0 taken 6402892 times.
✓ Branch 1 taken 12291863 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6402892 times.
18694755 if(z<=8&&fakez<=8)
7639 {
7640
2/2
✓ Branch 0 taken 42652 times.
✓ Branch 1 taken 6360240 times.
6402892 if (get_bit(quest_rules, qr_GRASS_SENSITIVE))
7641 {
7642 42652 bool g1 = isGrassType(COMBOTYPE(x+4,y+15)), g2 = isGrassType(COMBOTYPE(x+11,y+15)), g3 = isGrassType(COMBOTYPE(x+4,y+9)), g4 = isGrassType(COMBOTYPE(x+11,y+9));
7643
2/2
✓ Branch 0 taken 41531 times.
✓ Branch 1 taken 1121 times.
42652 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7644 {
7645
2/4
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1121 times.
1121 g1 = g1 || isGrassType(COMBOTYPEL(1,x+4,y+15)) || isGrassType(COMBOTYPEL(2,x+4,y+15));
7646
2/4
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1121 times.
1121 g2 = g2 || isGrassType(COMBOTYPEL(1,x+11,y+15)) || isGrassType(COMBOTYPEL(2,x+11,y+15));
7647
2/4
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1121 times.
1121 g3 = g3 || isGrassType(COMBOTYPEL(1,x+4,y+9)) || isGrassType(COMBOTYPEL(2,x+4,y+9));
7648
2/4
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1121 times.
1121 g4 = g4 || isGrassType(COMBOTYPEL(1,x+11,y+9)) || isGrassType(COMBOTYPEL(2,x+11,y+9));
7649 1121 }
7650
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42652 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42652 if(g1 && g2 && g3 && g4)
7651 {
7652 int grasscid = MAPCOMBO(x+8,y+12);
7653 newcombo const& cmb = combobuf[grasscid];
7654 if(decorations.idCount(dTALLGRASS)==0)
7655 {
7656 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
7657 }
7658 int32_t thesfx = cmb.attribytes[3];
7659 if (action==walking)
7660 sfx_no_repeat(thesfx,pan((int32_t)x));
7661 }
7662 42652 }
7663 else
7664 {
7665 6360240 bool g1 = isGrassType(COMBOTYPE(x,y+15)), g2 = isGrassType(COMBOTYPE(x+15,y+15));
7666
2/2
✓ Branch 0 taken 6345318 times.
✓ Branch 1 taken 14922 times.
6360240 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7667 {
7668
2/4
✓ Branch 0 taken 14922 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14922 times.
14922 g1 = g1 || isGrassType(COMBOTYPEL(1,x,y+15)) || isGrassType(COMBOTYPEL(2,x,y+15));
7669
2/4
✓ Branch 0 taken 14922 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14922 times.
14922 g2 = g2 || isGrassType(COMBOTYPEL(1,x+15,y+15)) || isGrassType(COMBOTYPEL(2,x+15,y+15));
7670 14922 }
7671
4/4
✓ Branch 0 taken 44398 times.
✓ Branch 1 taken 6315842 times.
✓ Branch 2 taken 5801 times.
✓ Branch 3 taken 38597 times.
6360240 if(g1 && g2)
7672 {
7673 38597 int grasscid = MAPCOMBO(x+8,y+15);
7674 38597 newcombo const& cmb = combobuf[grasscid];
7675
2/2
✓ Branch 0 taken 38045 times.
✓ Branch 1 taken 552 times.
38597 if(decorations.idCount(dTALLGRASS)==0)
7676 {
7677
3/6
✓ Branch 0 taken 552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 552 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 552 times.
✗ Branch 5 not taken.
552 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
7678 552 }
7679 38597 int32_t thesfx = cmb.attribytes[3];
7680
2/2
✓ Branch 0 taken 17055 times.
✓ Branch 1 taken 21542 times.
38597 if (action==walking )
7681 21542 sfx_no_repeat(thesfx,pan((int32_t)x));
7682 38597 }
7683 }
7684 6402892 }
7685
7686
2/2
✓ Branch 0 taken 12561616 times.
✓ Branch 1 taken 6133139 times.
18694755 if (get_bit(quest_rules, qr_SHALLOW_SENSITIVE))
7687 {
7688
19/26
✓ Branch 0 taken 269606 times.
✓ Branch 1 taken 12292010 times.
✓ Branch 2 taken 269606 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268327 times.
✓ Branch 5 taken 1279 times.
✓ Branch 6 taken 268327 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 267751 times.
✓ Branch 9 taken 576 times.
✓ Branch 10 taken 267751 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 267751 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 267751 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 267261 times.
✓ Branch 17 taken 490 times.
✓ Branch 18 taken 267261 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 267228 times.
✓ Branch 21 taken 33 times.
✓ Branch 22 taken 267168 times.
✓ Branch 23 taken 60 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267168 times.
12561616 if (z == 0 && fakez == 0 && action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7689 {
7690
2/2
✓ Branch 0 taken 244032 times.
✓ Branch 1 taken 23136 times.
291823 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
7691
2/2
✓ Branch 0 taken 24655 times.
✓ Branch 1 taken 242513 times.
267168 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
7692
2/2
✓ Branch 0 taken 23788 times.
✓ Branch 1 taken 867 times.
24655 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
7693
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 23170 times.
23788 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
7694 {
7695 23136 int watercheck_x = x.getInt()+7.5, watercheck_y = y.getInt()+12;
7696 23136 int ffpos = getFFCAt(watercheck_x,watercheck_y);
7697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23136 times.
23136 int combopos = ffpos < 0 ? COMBOPOS(watercheck_x,watercheck_y) : -1;
7698
4/8
✓ Branch 0 taken 23136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23136 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23136 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 23136 times.
23136 if(watercheck_x < 0 || watercheck_x > 255 || watercheck_y < 0 || watercheck_y > 175)
7699 combopos = -1;
7700
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23136 times.
✓ Branch 2 taken 23136 times.
✗ Branch 3 not taken.
23136 int waterid = ffpos > -1 ? tmpscr->ffcs[ffpos].getData() : (combopos > -1 ? tmpscr->data[combopos] : 0);
7701
1/2
✓ Branch 0 taken 23136 times.
✗ Branch 1 not taken.
23136 if(waterid)
7702 23136 waterid = iswaterex(waterid, currmap, currscr, -1, watercheck_x,watercheck_y, false, false, true, true);
7703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23136 times.
23136 if(waterid)
7704 {
7705 23136 newcombo const& watercmb = combobuf[waterid];
7706 23136 auto ripplesprite = watercmb.attribytes[6];
7707
2/2
✓ Branch 0 taken 22979 times.
✓ Branch 1 taken 157 times.
23136 if(decorations.idCount(dRIPPLES)==0)
7708
3/6
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 157 times.
✗ Branch 5 not taken.
157 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
7709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23136 times.
23136 if (watercmb.usrflags&cflag2)
7710 {
7711 if (!(current_item(watercmb.attribytes[2]) > 0 && current_item(watercmb.attribytes[2]) >= watercmb.attribytes[3]))
7712 {
7713 onpassivedmg = true;
7714 if (!damageovertimeclk)
7715 {
7716 int32_t curhp = game->get_life();
7717 auto dmg = watercmb.attributes[1]/10000L;
7718 auto hitsfx = watercmb.attributes[2]/10000L;
7719 bool hitstun = dmg < 0 && (watercmb.usrflags&cflag7);
7720
7721 if(game->get_life() == curhp && (watercmb.usrflags&cflag6))
7722 hitsfx = 0;
7723
7724 std::vector<int32_t> &ev = FFCore.eventData;
7725 ev.clear();
7726 ev.push_back(-dmg*10000);
7727 ev.push_back(-1*10000);
7728 ev.push_back(0);
7729 ev.push_back(0);
7730 ev.push_back(48*10000);
7731 ev.push_back(ZSD_COMBODATA*10000);
7732 ev.push_back(waterid);
7733 ev.push_back((ffpos > -1 ? ZSD_FFC : ZSD_COMBOPOS)*10000);
7734 ev.push_back(ffpos > -1 ? ffpos : combopos*10000);
7735
7736 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7737
7738 if(watercmb.usrflags & cflag5)
7739 ev[0] = ringpower(ev[0]/10000) * 10000;
7740
7741 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7742 dmg = -ev[0]/10000;
7743
7744 if(!ev[2]) //nullify
7745 {
7746 game->set_life(vbound(game->get_life()+dmg, 0, game->get_maxlife()));
7747 if (hitsfx)
7748 sfx(hitsfx);
7749 if (hitstun)
7750 {
7751 hclk = ev[4]/10000;
7752 hitdir = ev[1]/10000;
7753 action = gothit; FFCore.setHeroAction(gothit);
7754 }
7755 }
7756 }
7757 if (watercmb.attribytes[1] > 0)
7758 {
7759 if (!damageovertimeclk || damageovertimeclk > watercmb.attribytes[1]) damageovertimeclk = watercmb.attribytes[1];
7760 else --damageovertimeclk;
7761 }
7762 else damageovertimeclk = 0;
7763 }
7764 else damageovertimeclk = 0;
7765 }
7766 23136 else damageovertimeclk = 0;
7767 23136 int32_t thesfx = watercmb.attribytes[0];
7768
3/4
✓ Branch 0 taken 22806 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 22806 times.
✗ Branch 3 not taken.
23136 if (watercmb.type != cSHALLOWWATER || !get_bit(quest_rules, qr_OLD_SHALLOW_SFX))
7769 {
7770 330 thesfx = watercmb.attribytes[5];
7771 330 }
7772
2/2
✓ Branch 0 taken 12794 times.
✓ Branch 1 taken 10342 times.
23136 if (action==walking)
7773 10342 sfx_no_repeat(thesfx,pan((int32_t)x));
7774 23136 }
7775 23136 }
7776 267168 }
7777 12561616 }
7778 else
7779 {
7780
7/8
✓ Branch 0 taken 8860 times.
✓ Branch 1 taken 6124279 times.
✓ Branch 2 taken 8421 times.
✓ Branch 3 taken 439 times.
✓ Branch 4 taken 8421 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6124718 times.
✓ Branch 7 taken 8421 times.
6133139 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER) && z==0 && fakez==0)
7781 {
7782 8421 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
7783 8421 auto ripplesprite = combobuf[watercheck].attribytes[6];
7784
2/2
✓ Branch 0 taken 8358 times.
✓ Branch 1 taken 63 times.
8421 if(decorations.idCount(dRIPPLES)==0)
7785 {
7786
3/6
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✗ Branch 5 not taken.
63 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
7787 63 }
7788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8421 times.
8421 if (combobuf[watercheck].usrflags&cflag2)
7789 {
7790 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7791 {
7792 onpassivedmg = true;
7793 if (!damageovertimeclk)
7794 {
7795 int32_t curhp = game->get_life();
7796 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7797 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
7798 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7799 }
7800 if (combobuf[watercheck].attribytes[1] > 0)
7801 {
7802 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7803 else --damageovertimeclk;
7804 }
7805 else damageovertimeclk = 0;
7806 }
7807 else damageovertimeclk = 0;
7808 }
7809 8421 else damageovertimeclk = 0;
7810 8421 int32_t thesfx = combobuf[watercheck].attribytes[0];
7811
2/2
✓ Branch 0 taken 4914 times.
✓ Branch 1 taken 3507 times.
8421 if (action==walking )
7812 3507 sfx_no_repeat(thesfx,pan((int32_t)x));
7813 8421 }
7814 }
7815
7816
2/2
✓ Branch 0 taken 18694712 times.
✓ Branch 1 taken 43 times.
18694755 if(stomping)
7817 43 stomping = false;
7818
7819
1/2
✓ Branch 0 taken 18694755 times.
✗ Branch 1 not taken.
18694755 if(getOnSideviewLadder())
7820 {
7821 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
7822 {
7823 setOnSideviewLadder(false);
7824 }
7825 else if(CANFORCEFACEUP)
7826 {
7827 setDir(up);
7828 }
7829 }
7830
7831
6/8
✓ Branch 0 taken 6396802 times.
✓ Branch 1 taken 12297953 times.
✓ Branch 2 taken 6396226 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 6396226 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6396226 times.
18694755 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
7832 {
7833
2/2
✓ Branch 0 taken 6249947 times.
✓ Branch 1 taken 146279 times.
6396226 if(!get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
7834 {
7835 146279 checkchest(cCHEST);
7836 146279 checkchest(cLOCKEDCHEST);
7837 146279 checkchest(cBOSSCHEST);
7838 146279 }
7839
2/2
✓ Branch 0 taken 6379607 times.
✓ Branch 1 taken 16619 times.
6396226 if(!get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
7840 {
7841 16619 checkchest(cLOCKBLOCK);
7842 16619 checkchest(cBOSSLOCKBLOCK);
7843 16619 }
7844 6396226 }
7845 18694755 checksigns();
7846 18694755 checkgenpush();
7847
7848
4/4
✓ Branch 0 taken 6056670 times.
✓ Branch 1 taken 12638085 times.
✓ Branch 2 taken 6054478 times.
✓ Branch 3 taken 2192 times.
18694755 if(isStanding(true) && fall == 0)
7849 {
7850
1/2
✓ Branch 0 taken 6054478 times.
✗ Branch 1 not taken.
6054478 if(extra_jump_count > 0)
7851 extra_jump_count = 0;
7852 6054478 coyotetime = 0;
7853 6054478 }
7854
2/2
✓ Branch 0 taken 12289312 times.
✓ Branch 1 taken 350965 times.
12640277 else if(coyotetime < 65535)
7855 {
7856 350965 ++coyotetime;
7857 350965 }
7858
2/2
✓ Branch 0 taken 18684664 times.
✓ Branch 1 taken 10091 times.
18694755 if(can_use_item(itype_hoverboots,i_hoverboots))
7859 {
7860 10091 int32_t hoverid = current_item_id(itype_hoverboots);
7861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10091 times.
10091 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
7862 {
7863
1/2
✓ Branch 0 taken 10091 times.
✗ Branch 1 not taken.
10091 if(hoverclk < 0) hoverclk = 0;
7864 10091 hoverflags &= ~HOV_OUT;
7865 10091 }
7866 10091 }
7867 18694755 bool platformfell2 = false;
7868 18694755 int32_t gravity3 = (zinit.gravity2/100);
7869 18694755 int32_t termv = (zinit.terminalv);
7870 18694755 int32_t rocs = getRocsPressed();
7871
2/2
✓ Branch 0 taken 18694451 times.
✓ Branch 1 taken 304 times.
18694755 if (rocs != -1)
7872 {
7873 304 itemdata const& itm = itemsbuf[rocs];
7874
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (itm.flags & ITEM_FLAG2)
7875 {
7876 if ((!(itm.flags & ITEM_FLAG3) || fall < 0) &&
7877 (!(itm.flags & ITEM_FLAG4) || fall > 0)) gravity3 = itm.misc3;
7878 }
7879
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (itm.flags & ITEM_FLAG5)
7880 {
7881 termv = itm.misc4;
7882 if (fall > termv) fall = termv;
7883 }
7884 304 }
7885
2/2
✓ Branch 0 taken 250696 times.
✓ Branch 1 taken 18444059 times.
18694755 if(sideview_mode()) // Sideview gravity
7886 {
7887 //Handle falling through a platform
7888 250696 bool platformfell = false;
7889
3/4
✓ Branch 0 taken 126181 times.
✓ Branch 1 taken 124515 times.
✓ Branch 2 taken 126181 times.
✗ Branch 3 not taken.
250696 if (on_sideview_solid_oldpos(x,y,old_x,old_y,true,3) && !on_sideview_solid_oldpos(x,y,old_x,old_y,false,3))
7890 {
7891 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
7892 y+=1; //Fall down a pixel instantly, through the platform.
7893 if(fall < 0) fall = 0;
7894 if(jumping < 0) jumping = 0;
7895 platformfell2 = true;
7896 }
7897 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
7898
1/2
✓ Branch 0 taken 250696 times.
✗ Branch 1 not taken.
250696 if(!get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
7899 {
7900 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
7901 || ((y+(fall/100)<=0) &&
7902 // Extra checks if Smart Screen Scrolling is enabled
7903 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7904 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
7905 {
7906 fall = jumping = 0; // Bumped his head
7907 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7908 y -= y.getInt()%8; //fix coords
7909 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7910 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7911 {
7912 checkdamagecombos(x+4, x+12, y-1, y-1);
7913 }
7914 }
7915 }
7916 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
7917
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 250696 times.
✓ Branch 2 taken 250696 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250696 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250696 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 250696 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 250696 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 250696 times.
250696 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
7918 {
7919
1/2
✓ Branch 0 taken 250696 times.
✗ Branch 1 not taken.
250696 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
7920 //zprint2("ydif is: %d\n", ydiff);
7921 //zprint2("ydif is: %d\n", (int32_t)fall);
7922 250696 falling_oldy = y; // Stomp Boots-related variable
7923
5/8
✓ Branch 0 taken 46982 times.
✓ Branch 1 taken 203714 times.
✓ Branch 2 taken 46982 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46982 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250696 times.
✗ Branch 7 not taken.
250696 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
7924 {
7925 ydiff -= (y.getInt()+ydiff)%16;
7926 }
7927
3/4
✓ Branch 0 taken 66794 times.
✓ Branch 1 taken 183902 times.
✓ Branch 2 taken 66794 times.
✗ Branch 3 not taken.
250696 if(ydiff && !get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7928 {
7929 if(ydiff > 0)
7930 {
7931 for(auto q = 0; q < ydiff; ++q)
7932 {
7933 if(on_sideview_solid_oldpos(x,y+q,old_x,old_y))
7934 {
7935 ydiff = q;
7936 break;
7937 }
7938 }
7939 }
7940 else if(ydiff < 0)
7941 {
7942 for(auto q = 0; q > ydiff; --q)
7943 {
7944 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
7945 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
7946 {
7947 ydiff = q;
7948 break;
7949 }
7950 }
7951 }
7952 }
7953 250696 y+=ydiff;
7954 250696 hs_starty+=ydiff;
7955
7956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250696 times.
250696 for(int32_t j=0; j<chainlinks.Count(); j++)
7957 {
7958 chainlinks.spr(j)->y+=ydiff;
7959 }
7960
7961
1/2
✓ Branch 0 taken 250696 times.
✗ Branch 1 not taken.
250696 if(Lwpns.idFirst(wHookshot)>-1)
7962 {
7963 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
7964 }
7965
7966
1/2
✓ Branch 0 taken 250696 times.
✗ Branch 1 not taken.
250696 if(Lwpns.idFirst(wHSHandle)>-1)
7967 {
7968 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
7969 }
7970 250696 }
7971 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
7972 {
7973 fall = hoverclk = jumping = 0;
7974 inair = false;
7975 hoverflags = 0;
7976 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
7977 {
7978 WalkflagInfo info;
7979 if (game->get_watergrav()<0)
7980 {
7981 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
7982 execute(info);
7983 }
7984 else
7985 {
7986 info = walkflag(x,y+15+2,2,down);
7987 execute(info);
7988 }
7989 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
7990 }
7991 }
7992 // Stop hovering/falling if you land on something.
7993 250696 bool needFall = false;
7994
6/8
✓ Branch 0 taken 124036 times.
✓ Branch 1 taken 126660 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 250696 times.
✓ Branch 4 taken 126660 times.
✓ Branch 5 taken 124036 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 126660 times.
250696 if((on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
7995 {
7996 126660 stop_item_sfx(itype_hoverboots);
7997
1/2
✓ Branch 0 taken 126660 times.
✗ Branch 1 not taken.
126660 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7998 {
7999
4/6
✓ Branch 0 taken 126660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124016 times.
✓ Branch 3 taken 2644 times.
✓ Branch 4 taken 124016 times.
✗ Branch 5 not taken.
126660 if(!getOnSideviewLadder() && (fall > 0 || get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON)))
8000 {
8001 126660 y.doFloor();
8002 126660 y-=(int32_t)y%8; //fix position
8003 126660 }
8004 126660 }
8005 else
8006 {
8007 snap_platform();
8008 }
8009 126660 fall = hoverclk = jumping = 0;
8010 126660 inair = false;
8011 126660 hoverflags = 0;
8012
8013
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 126652 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
126660 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
8014 8 y = 160;
8015 126660 }
8016 // Stop hovering if you press down.
8017
3/6
✓ Branch 0 taken 124036 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124036 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124036 times.
✗ Branch 5 not taken.
124036 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
8018 {
8019 stop_item_sfx(itype_hoverboots);
8020 hoverclk = -hoverclk;
8021 reset_ladder();
8022 fall = gravity3;
8023 inair = false;
8024 }
8025
9/12
✓ Branch 0 taken 124036 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2713 times.
✓ Branch 3 taken 121323 times.
✓ Branch 4 taken 1008 times.
✓ Branch 5 taken 1705 times.
✓ Branch 6 taken 1008 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1008 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 281 times.
✓ Branch 11 taken 727 times.
124036 else if (hoverclk < 1 && !inair && fall == 0 && !platformfell && !IsSideSwim() && justmoved <= 0)
8026 {
8027 727 zfix my = y + 4;
8028 727 needFall = true;
8029
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 1968 times.
2569 for (zfix ty = y+1; ty < my; ++ty)
8030 {
8031 //if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 1)) break;
8032
2/2
✓ Branch 0 taken 1842 times.
✓ Branch 1 taken 126 times.
1968 if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 0))
8033 {
8034 126 y = ty;
8035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
8036 {
8037 if(!slopeid)
8038 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
8039 onplatid = 5;
8040 }
8041 126 needFall = false;
8042 126 break;
8043 }
8044 1842 }
8045 727 }
8046 123309 else needFall = true;
8047 // Continue falling.
8048
8049
4/4
✓ Branch 0 taken 243442 times.
✓ Branch 1 taken 7254 times.
✓ Branch 2 taken 126786 times.
✓ Branch 3 taken 116656 times.
250696 if(fall <= termv && needFall)
8050 {
8051 116656 inair = true;
8052
3/4
✓ Branch 0 taken 47035 times.
✓ Branch 1 taken 69621 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47035 times.
116656 if(fall != 0 || hoverclk>0)
8053 69621 jumping++;
8054
8055 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8056
1/2
✓ Branch 0 taken 116656 times.
✗ Branch 1 not taken.
116656 if(get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
8057 {
8058
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116656 times.
✓ Branch 4 taken 116065 times.
✓ Branch 5 taken 591 times.
233312 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8059
4/4
✓ Branch 0 taken 111190 times.
✓ Branch 1 taken 5466 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 110284 times.
116656 || (y<=(bigHitbox?9:1) &&
8060 // Extra checks if Smart Screen Scrolling is enabled
8061
2/6
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 906 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
906 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8062 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8063
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
5466 && fall < 0)
8064 {
8065 591 fall = jumping = 0; // Bumped his head
8066
8067 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8068
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 110 times.
591 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8069 {
8070 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8071 110 }
8072 591 }
8073 116656 }
8074 else
8075 {
8076 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8077 || ((y<=0) &&
8078 // Extra checks if Smart Screen Scrolling is enabled
8079 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8080 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8081 && fall < 0)
8082 {
8083 fall = jumping = 0; // Bumped his head
8084 y -= y.getInt()%8; //fix coords
8085 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8086 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8087 {
8088 checkdamagecombos(x+4, x+12, y-1, y-1);
8089 }
8090 }
8091 }
8092
8093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116656 times.
116656 if(hoverclk > 0)
8094 {
8095 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8096 {
8097 --hoverclk;
8098 }
8099
8100 if(!hoverclk && !ladderx && !laddery)
8101 {
8102 fall += gravity3;
8103 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8104 }
8105 }
8106
5/12
✓ Branch 0 taken 84816 times.
✓ Branch 1 taken 31840 times.
✓ Branch 2 taken 47732 times.
✓ Branch 3 taken 37084 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47732 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
116656 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8107 {
8108 int32_t itemid = current_item_id(itype_hoverboots);
8109 if(hoverclk < 0)
8110 hoverclk = -hoverclk;
8111 else
8112 {
8113 fall = jumping = 0;
8114 if(itemsbuf[itemid].misc1)
8115 hoverclk = itemsbuf[itemid].misc1;
8116 else
8117 {
8118 hoverclk = 1;
8119 hoverflags |= HOV_INF;
8120 }
8121
8122
8123 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8124 }
8125 if(itemsbuf[itemid].wpn)
8126 decorations.add(new dHover(x, y, dHOVER, 0));
8127 }
8128
4/8
✓ Branch 0 taken 116656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116656 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116656 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 116656 times.
116656 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8129 {
8130 116656 fall += gravity3;
8131
8132 116656 }
8133 116656 }
8134 250696 }
8135 else // Topdown gravity
8136 {
8137
4/4
✓ Branch 0 taken 12288254 times.
✓ Branch 1 taken 6155805 times.
✓ Branch 2 taken 848 times.
✓ Branch 3 taken 6154957 times.
18444059 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8138
4/4
✓ Branch 0 taken 12288254 times.
✓ Branch 1 taken 6155805 times.
✓ Branch 2 taken 848 times.
✓ Branch 3 taken 6154957 times.
18444059 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
8139
4/4
✓ Branch 0 taken 6151897 times.
✓ Branch 1 taken 12292162 times.
✓ Branch 2 taken 12296070 times.
✓ Branch 3 taken 18447967 times.
18444059 if(z>0||fakez>0)
8140 {
8141
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3908 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24588232 switch(action)
8142 {
8143 case swimming:
8144 {
8145 diveclk=0;
8146 action=walking; FFCore.setHeroAction(walking);
8147
8148 break;
8149 }
8150 case waterhold1:
8151 {
8152 action=landhold1; FFCore.setHeroAction(landhold1);
8153 break;
8154 }
8155
8156 case waterhold2:
8157 {
8158 action=landhold2; FFCore.setHeroAction(landhold2);
8159 break;
8160 }
8161
8162 default:
8163 3908 break;
8164 }
8165 3908 }
8166
8167
2/2
✓ Branch 0 taken 16982 times.
✓ Branch 1 taken 18451875 times.
18468857 for(int32_t j=0; j<chainlinks.Count(); j++)
8168 {
8169 16982 chainlinks.spr(j)->z=z;
8170 16982 chainlinks.spr(j)->fakez=fakez;
8171 16982 }
8172
8173
2/2
✓ Branch 0 taken 4511 times.
✓ Branch 1 taken 18447364 times.
18451875 if(Lwpns.idFirst(wHookshot)>-1)
8174 {
8175 4511 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8176 4511 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8177 4511 }
8178
8179
2/2
✓ Branch 0 taken 4732 times.
✓ Branch 1 taken 18447143 times.
18451875 if(Lwpns.idFirst(wHSHandle)>-1)
8180 {
8181 4732 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8182 4732 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8183 4732 }
8184
8185
3/4
✓ Branch 0 taken 6151897 times.
✓ Branch 1 taken 12299978 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6151897 times.
18451875 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8186 {
8187
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6151897 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6151897 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8188 {
8189
2/2
✓ Branch 0 taken 6151854 times.
✓ Branch 1 taken 43 times.
6151897 if(fall > 0)
8190 {
8191
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37 times.
✓ Branch 7 taken 6 times.
43 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8192 6 sfx(WAV_ZN1SPLASH,x.getInt());
8193
8194 43 stomping = true;
8195 43 }
8196 6151897 }
8197 6151897 z = fall = 0;
8198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6151897 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6151897 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8199 {
8200 6151897 jumping = 0;
8201
2/2
✓ Branch 0 taken 6151346 times.
✓ Branch 1 taken 551 times.
6151897 if(check_pitslide(true) == -1)
8202 {
8203 6151346 hoverclk = 0;
8204 6151346 hoverflags = 0;
8205 6151346 }
8206
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 534 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
551 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8207 {
8208
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8209 {
8210 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8211 }
8212 17 }
8213 6151897 }
8214 6151897 }
8215
3/4
✓ Branch 0 taken 6155805 times.
✓ Branch 1 taken 12296070 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6155805 times.
18451875 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8216 {
8217
3/4
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 6151897 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3908 times.
6155805 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8218 {
8219
1/2
✓ Branch 0 taken 6151897 times.
✗ Branch 1 not taken.
6151897 if(fakefall > 0)
8220 {
8221 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8222 sfx(WAV_ZN1SPLASH,x.getInt());
8223
8224 stomping = true;
8225 }
8226 6151897 }
8227 6155805 fakez = fakefall = 0;
8228
3/4
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 6151897 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3908 times.
6155805 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8229 {
8230 6151897 jumping = 0;
8231
2/2
✓ Branch 0 taken 6151346 times.
✓ Branch 1 taken 551 times.
6151897 if(check_pitslide(true) == -1)
8232 {
8233 6151346 hoverclk = 0;
8234 6151346 hoverflags = 0;
8235 6151346 }
8236
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 534 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
551 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8237 {
8238
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8239 {
8240 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8241 }
8242 17 }
8243 6151897 }
8244 6155805 }
8245
8/10
✓ Branch 0 taken 6155782 times.
✓ Branch 1 taken 12296093 times.
✓ Branch 2 taken 6155782 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6148035 times.
✓ Branch 5 taken 7747 times.
✓ Branch 6 taken 6151920 times.
✓ Branch 7 taken 6151920 times.
✓ Branch 8 taken 6151920 times.
✗ Branch 9 not taken.
18451875 if(fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8246 {
8247
4/6
✓ Branch 0 taken 2731 times.
✓ Branch 1 taken 1154 times.
✓ Branch 2 taken 2731 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2731 times.
12299955 if(fall != 0 || fakefall != 0 || hoverclk>0)
8248 1154 jumping++;
8249
8250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3885 times.
3885 if(hoverclk > 0)
8251 {
8252 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8253 {
8254 --hoverclk;
8255 }
8256
8257 if(!hoverclk)
8258 {
8259 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8260 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8261 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8262 }
8263 }
8264
9/16
✓ Branch 0 taken 3377 times.
✓ Branch 1 taken 508 times.
✓ Branch 2 taken 2741 times.
✓ Branch 3 taken 636 times.
✓ Branch 4 taken 2741 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1144 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1144 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1144 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3885 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3885 else if(((fall+(int32_t)(zinit.gravity2 / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8265 {
8266 if(hoverclk < 0)
8267 hoverclk = -hoverclk;
8268 else
8269 {
8270 fall = 0;
8271 fakefall = 0;
8272 int32_t itemid = current_item_id(itype_hoverboots);
8273 if(itemsbuf[itemid].misc1)
8274 hoverclk = itemsbuf[itemid].misc1;
8275 else
8276 {
8277 hoverclk = 1;
8278 hoverflags |= HOV_INF;
8279 }
8280 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8281 }
8282 decorations.add(new dHover(x, y, dHOVER, 0));
8283 }
8284 else
8285 {
8286
3/6
✓ Branch 0 taken 3885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3885 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3885 times.
3885 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8287
3/6
✓ Branch 0 taken 3885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3885 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3885 times.
✗ Branch 5 not taken.
3885 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8288 }
8289 3885 }
8290
1/2
✓ Branch 0 taken 6155805 times.
✗ Branch 1 not taken.
6155805 if (fakez<0) fakez = 0;
8291
1/2
✓ Branch 0 taken 6155805 times.
✗ Branch 1 not taken.
6155805 if (z<0) z = 0;
8292 }
8293
8294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6406501 times.
6406501 if(drunkclk)
8295 {
8296 --drunkclk;
8297 }
8298
8299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6406501 times.
6406501 if(lstunclock > 0)
8300 {
8301 // also cancel Hero's attack
8302 attackclk = 0;
8303
8304 if( FFCore.getHeroAction() != stunned )
8305 {
8306 tempaction=action; //update so future checks won't do this
8307 //action=freeze; //setting this makes the player invincible while stunned -V
8308 FFCore.setHeroAction(stunned);
8309 }
8310 --lstunclock;
8311 }
8312 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8313 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8314
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6406501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6406501 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8315 {
8316 action=tempaction; FFCore.setHeroAction(tempaction);
8317 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8318 //action=none; FFCore.setHeroAction(none);
8319 }
8320
8321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6406501 times.
6406501 if( lbunnyclock > 0 )
8322 {
8323 --lbunnyclock;
8324 }
8325
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 6404576 times.
6406501 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8326 {
8327 1925 int32_t itemid = current_item_id(itype_pearl);
8328
2/2
✓ Branch 0 taken 1802 times.
✓ Branch 1 taken 123 times.
1925 if(itemid > -1)
8329 {
8330
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 1 times.
123 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8331 1 lbunnyclock = 0;
8332 123 }
8333
2/2
✓ Branch 0 taken 1801 times.
✓ Branch 1 taken 1 times.
1802 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8334 {
8335 1 lbunnyclock = -1;
8336 1 }
8337 1925 }
8338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6404576 times.
6404576 else if(lbunnyclock == -1) //dmap-caused bunny effect
8339 {
8340 lbunnyclock = 0;
8341 }
8342
8343
13/18
✓ Branch 0 taken 6398666 times.
✓ Branch 1 taken 7835 times.
✓ Branch 2 taken 5698019 times.
✓ Branch 3 taken 700647 times.
✓ Branch 4 taken 5698019 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5698019 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1206 times.
✓ Branch 9 taken 5696813 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1206 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 5696210 times.
✓ Branch 15 taken 1809 times.
✓ Branch 16 taken 45294 times.
✓ Branch 17 taken 5650322 times.
6406501 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && (fall==0 || fakefall==0 || z>0 || fakez>0) && charging==0 && spins<=5
8344
2/2
✓ Branch 0 taken 5695616 times.
✓ Branch 1 taken 594 times.
5696210 && action != gothit)
8345 {
8346
2/3
✓ Branch 0 taken 2533324 times.
✓ Branch 1 taken 3116998 times.
✗ Branch 2 not taken.
5650322 switch(dir)
8347 {
8348 case up:
8349 case down:
8350 2533324 x=(x.getInt()+4)&0xFFF8;
8351 2533324 break;
8352
8353 case left:
8354 case right:
8355 3116998 y=(y.getInt()+4)&0xFFF8;
8356 3116998 break;
8357 }
8358 5650322 }
8359
8360
4/4
✓ Branch 0 taken 116936 times.
✓ Branch 1 taken 6289565 times.
✓ Branch 2 taken 77419 times.
✓ Branch 3 taken 39517 times.
6406501 if((watch==true) && clockclk)
8361 {
8362 39517 --clockclk;
8363
8364
2/2
✓ Branch 0 taken 39410 times.
✓ Branch 1 taken 107 times.
39517 if(!clockclk)
8365 {
8366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(cheat_superman==false)
8367 {
8368 107 setClock(false);
8369 107 }
8370
8371 107 watch=false;
8372
8373
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 107 times.
54891 for(int32_t i=0; i<eMAXGUYS; i++)
8374 {
8375
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 54784 times.
54790 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
8376 {
8377 6 addenemy(0,0,i,0);
8378 6 }
8379 54784 }
8380 107 }
8381 39517 }
8382
8383
3/4
✓ Branch 0 taken 6401769 times.
✓ Branch 1 taken 4732 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6401769 times.
6406501 if(hookshot_frozen || switch_hooked)
8384 {
8385
3/4
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 4511 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 221 times.
4732 if(hookshot_used || switch_hooked)
8386 {
8387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4511 times.
4511 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8388 4511 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8389
8390
3/4
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3888 times.
4511 if(pull_hero || switch_hooked)
8391 {
8392
3/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 563 times.
623 if(hs_switcher || switch_hooked)
8393 {
8394 60 hs_fix = false;
8395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(switchhookclk)
8396 {
8397 60 --switchhookclk;
8398
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 59 times.
60 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8399 {
8400
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8401 reset_hookshot();
8402 else
8403 {
8404 1 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8405 1 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8406
8407
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hooked_combopos > -1) //Switching combos
8408 {
8409 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
8410 if(targpos < 176 && plpos < 176 && hooked_layerbits)
8411 {
8412 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8413 for(int q = max_layer; q > -1; --q)
8414 {
8415 if(!(hooked_layerbits & (1<<q)))
8416 continue; //non-switching layer
8417 mapscr* scr = FFCore.tempScreens[q];
8418 newcombo const& cmb = combobuf[scr->data[targpos]];
8419 int32_t srcfl = scr->sflag[targpos];
8420 newcombo const& comb2 = combobuf[scr->data[plpos]];
8421 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
8422 //{Check push status
8423 bool isFakePush = false;
8424 if(cmb.type == cSWITCHHOOK)
8425 {
8426 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8427 isFakePush = true;
8428 }
8429 bool isPush = isFakePush;
8430 if(!isPush) switch(srcfl)
8431 {
8432 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8433 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8434 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8435 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8436 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8437 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8438 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8439 isPush = true;
8440 }
8441 if(!isPush) switch(cmb.flag)
8442 {
8443 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8444 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8445 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8446 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8447 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8448 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8449 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8450 isPush = true;
8451 }
8452 if(srcfl==mfPUSHED) isPush = false;
8453 //}
8454 if(cmb.type == cSWITCHHOOK) //custom flags and such
8455 {
8456 if(cmb.usrflags&cflag3) //Breaks on swap
8457 {
8458 int32_t it = -1;
8459 int32_t thedropset = -1;
8460 if(cmb.usrflags&cflag4) //drop item
8461 {
8462 if(cmb.usrflags&cflag5)
8463 it = cmb.attribytes[2];
8464 else
8465 {
8466 it = select_dropitem(cmb.attribytes[2]);
8467 thedropset = cmb.attribytes[2];
8468 }
8469 }
8470
8471 breakable* br = new breakable(x, y, zfix(0),
8472 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
8473 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8474 br->switch_hooked = true;
8475 decorations.add(br);
8476 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8477 hooked_undercombos[q] = -1;
8478
8479 if(cmb.usrflags&cflag6)
8480 {
8481 scr->data[targpos]++;
8482 }
8483 else
8484 {
8485 scr->data[targpos] = scr->undercombo;
8486 scr->cset[targpos] = scr->undercset;
8487 if(cmb.usrflags&cflag2)
8488 scr->sflag[targpos] = 0;
8489 }
8490 }
8491 else if(isPush)
8492 {
8493 //Simulate a block clicking into place
8494 movingblock mtemp;
8495 mtemp.clear();
8496 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8497 mtemp.dir = getPushDir(scr->sflag[targpos]);
8498 if(mtemp.dir < 0)
8499 mtemp.dir = getPushDir(cmb.flag);
8500 mtemp.clk = 1;
8501 mtemp.force_many = isFakePush;
8502 mtemp.no_icy = true;
8503 mtemp.animate(0);
8504 if((mtemp.bhole || mtemp.trigger)
8505 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8506 || comb2.flag == mfBLOCKTRIGGER
8507 || comb2.flag == mfBLOCKHOLE))
8508 {
8509 scr->data[targpos] = scr->undercombo;
8510 scr->cset[targpos] = scr->undercset;
8511 scr->sflag[targpos] = 0;
8512 }
8513 else
8514 {
8515 scr->data[targpos] = c;
8516 scr->cset[targpos] = cs;
8517 if(cmb.usrflags&cflag2)
8518 scr->sflag[targpos] = fl;
8519 else
8520 scr->sflag[targpos] = 0;
8521 }
8522 }
8523 else
8524 {
8525 scr->data[plpos] = scr->data[targpos];
8526 scr->cset[plpos] = scr->cset[targpos];
8527 if(cmb.usrflags&cflag2)
8528 scr->sflag[plpos] = scr->sflag[targpos];
8529 scr->data[targpos] = c;
8530 scr->cset[targpos] = cs;
8531 if(cmb.usrflags&cflag2)
8532 scr->sflag[targpos] = fl;
8533 }
8534 }
8535 else if(isCuttableType(cmb.type)) //Break and drop effects
8536 {
8537 int32_t breakcs = scr->cset[targpos];
8538 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8539 {
8540 scr->data[targpos]++;
8541 }
8542 else
8543 {
8544 scr->data[targpos] = scr->undercombo;
8545 scr->cset[targpos] = scr->undercset;
8546 scr->sflag[targpos] = 0;
8547 }
8548
8549 int32_t it = -1;
8550 int32_t thedropset = -1;
8551 if(isCuttableItemType(cmb.type)) //Drop an item
8552 {
8553 if ( (cmb.usrflags&cflag2) )
8554 {
8555 if(cmb.usrflags&cflag11)
8556 it = cmb.attribytes[1];
8557 else
8558 {
8559 it = select_dropitem(cmb.attribytes[1]);
8560 thedropset = cmb.attribytes[1];
8561 }
8562 }
8563 else
8564 {
8565 it = select_dropitem(12);
8566 thedropset = 12;
8567 }
8568 }
8569
8570 byte breaksfx = 0;
8571 if(get_bit(quest_rules,qr_MORESOUNDS)) //SFX
8572 {
8573 if (cmb.usrflags&cflag3)
8574 {
8575 breaksfx = cmb.attribytes[2];
8576 }
8577 else if(isBushType(cmb.type)
8578 || isFlowersType(cmb.type)
8579 || isGrassType(cmb.type))
8580 {
8581 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8582 }
8583 }
8584
8585 //Clipping sprite
8586 int16_t decotype = (cmb.usrflags & cflag1) ?
8587 ((cmb.usrflags & cflag10)
8588 ? (cmb.attribytes[0])
8589 : (-1))
8590 : (0);
8591 if(decotype > 3) decotype = 0;
8592 if(!decotype)
8593 decotype = (isBushType(cmb.type) ? 1
8594 : (isFlowersType(cmb.type) ? 2
8595 : (isGrassType(cmb.type) ? 3
8596 : ((cmb.usrflags & cflag1) ? -1
8597 : -2))));
8598
8599 breakable* br = new breakable(x, y, zfix(0),
8600 cmb, breakcs, it, thedropset, breaksfx,
8601 decotype, cmb.attribytes[0], switchhookclk);
8602 br->switch_hooked = true;
8603 decorations.add(br);
8604 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8605 hooked_undercombos[q] = -1;
8606 }
8607 else //Unknown type, just swap combos.
8608 {
8609 if(isPush)
8610 {
8611 //Simulate a block clicking into place
8612 movingblock mtemp;
8613 mtemp.clear();
8614 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8615 mtemp.dir = getPushDir(scr->sflag[targpos]);
8616 if(mtemp.dir < 0)
8617 mtemp.dir = getPushDir(cmb.flag);
8618 mtemp.clk = 1;
8619 mtemp.animate(0);
8620 if(mtemp.bhole || mtemp.trigger)
8621 {
8622 scr->data[targpos] = scr->undercombo;
8623 scr->cset[targpos] = scr->undercset;
8624 scr->sflag[targpos] = 0;
8625 }
8626 else
8627 {
8628 scr->data[targpos] = c;
8629 scr->cset[targpos] = cs;
8630 scr->sflag[targpos] = 0;
8631 }
8632 }
8633 else
8634 {
8635 scr->data[plpos] = scr->data[targpos];
8636 scr->cset[plpos] = scr->cset[targpos];
8637 scr->data[targpos] = c;
8638 scr->cset[targpos] = cs;
8639 }
8640 }
8641 }
8642 if(switchhook_cost_item > -1)
8643 paymagiccost(switchhook_cost_item);
8644 zfix tx = x, ty = y;
8645 //Position the player at the combo
8646 x = COMBOX(targpos);
8647 y = COMBOY(targpos);
8648 dir = oppositeDir[dir];
8649 if(w && hw)
8650 {
8651 //Calculate chain shift
8652 zfix dx = (x-tx);
8653 zfix dy = (y-ty);
8654 if(w->dir < 4)
8655 {
8656 if(w->dir & 2)
8657 dx = 0;
8658 else dy = 0;
8659 }
8660 //Position the hook head at the handle
8661 w->x = hw->x + dx;
8662 w->y = hw->y + dy;
8663 w->dir = oppositeDir[w->dir];
8664 w->doAutoRotate(true);
8665 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8666 w->flip ^= hflip;
8667 //Position the handle appropriately
8668 hw->x = x-(hw->x-tx);
8669 hw->y = y-(hw->y-ty);
8670 hw->dir = oppositeDir[hw->dir];
8671 hw->doAutoRotate(true);
8672 hw->flip ^= hflip;
8673 //Move chains
8674 for(int32_t j=0; j<chainlinks.Count(); j++)
8675 {
8676 chainlinks.spr(j)->x += dx;
8677 chainlinks.spr(j)->y += dy;
8678 }
8679 }
8680 hooked_combopos = plpos; //flip positions
8681 }
8682 else reset_hookshot();
8683 }
8684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object) //Switching an object
8685 {
8686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(switchhook_cost_item > -1)
8687 paymagiccost(switchhook_cost_item);
8688 1 zfix tx = x, ty = y;
8689 //Position the player at the object
8690 1 x = switching_object->x;
8691 1 y = switching_object->y;
8692 1 dir = oppositeDir[dir];
8693 //Position the object at the player
8694 1 switching_object->x = tx;
8695 1 switching_object->y = ty;
8696
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
8697 switching_object->dir = oppositeDir[switching_object->dir];
8698 1 solid_update(false);
8699 1 switching_object->solid_update(false);
8700
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(item* it = dynamic_cast<item*>(switching_object))
8701 {
8702 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
8703 {
8704 movefairynew2(it->x, it->y, *it);
8705 }
8706 }
8707
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(w && hw) //!TODO No fucking clue if diagonals work
8708 {
8709 //Calculate chain shift
8710 1 zfix dx = (x-tx);
8711 1 zfix dy = (y-ty);
8712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w->dir < 4)
8713 {
8714
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->dir & 2)
8715 1 dx = 0;
8716 else dy = 0;
8717 1 }
8718 //Position the hook head at the handle
8719 1 w->x = hw->x + dx;
8720 1 w->y = hw->y + dy;
8721 1 w->dir = oppositeDir[w->dir];
8722 1 w->doAutoRotate(true);
8723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8724 1 w->flip ^= hflip;
8725 1 w->solid_update(false);
8726 //Position the handle appropriately
8727 1 hw->x = x-(hw->x-tx);
8728 1 hw->y = y-(hw->y-ty);
8729 1 hw->dir = oppositeDir[hw->dir];
8730 1 hw->doAutoRotate(true);
8731 1 hw->flip ^= hflip;
8732 1 hw->solid_update(false);
8733 //Move chains
8734
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
8735 {
8736 5 chainlinks.spr(j)->x += dx;
8737 5 chainlinks.spr(j)->y += dy;
8738 5 }
8739 1 }
8740 1 }
8741 }
8742 1 }
8743
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 1 times.
59 else if(!switchhookclk)
8744 {
8745 1 reset_hookshot();
8746 1 }
8747 60 }
8748 else reset_hookshot();
8749 60 }
8750 else
8751 {
8752 sprite *t;
8753 int32_t i;
8754
8755
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 579 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 563 times.
579 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
8756 {
8757 /* do nothing */
8758 16 }
8759
8760 563 t = Lwpns.spr(i);
8761
8762
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 563 times.
1705 for(i=0; i<Lwpns.Count(); i++)
8763 {
8764 1142 sprite *s = Lwpns.spr(i);
8765
8766
2/2
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 563 times.
1142 if(s->id==wHookshot)
8767 {
8768
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 500 times.
563 if (abs((s->y) - y) >= 1)
8769 {
8770
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 38 times.
63 if((s->y)>y)
8771 {
8772 38 y+=4;
8773
8774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(Lwpns.idFirst(wHSHandle)!=-1)
8775 {
8776 38 t->y+=4;
8777 38 }
8778
8779 38 hs_starty+=4;
8780 38 }
8781
8782
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 25 times.
63 if((s->y)<y)
8783 {
8784 25 y-=4;
8785
8786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Lwpns.idFirst(wHSHandle)!=-1)
8787 {
8788 25 t->y-=4;
8789 25 }
8790
8791 25 hs_starty-=4;
8792 25 }
8793 63 }
8794 else
8795 {
8796 500 y = (s->y);
8797 }
8798
2/2
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 63 times.
563 if (abs((s->x) - x) >= 1)
8799 {
8800
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 338 times.
500 if((s->x)>x)
8801 {
8802 338 x+=4;
8803
8804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 338 times.
338 if(Lwpns.idFirst(wHSHandle)!=-1)
8805 {
8806 338 t->x+=4;
8807 338 }
8808
8809 338 hs_startx+=4;
8810 338 }
8811
8812
2/2
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 162 times.
500 if((s->x)<x)
8813 {
8814 162 x-=4;
8815
8816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if(Lwpns.idFirst(wHSHandle)!=-1)
8817 {
8818 162 t->x-=4;
8819 162 }
8820
8821 162 hs_startx-=4;
8822 162 }
8823 500 }
8824 else
8825 {
8826 63 x = (s->x);
8827 }
8828 563 }
8829 1142 }
8830 }
8831 623 }
8832 4511 }
8833 else
8834 {
8835 221 Lwpns.del(Lwpns.idFirst(wHSHandle));
8836 221 reset_hookshot();
8837 }
8838
8839
1/2
✓ Branch 0 taken 4732 times.
✗ Branch 1 not taken.
4732 if(hs_fix)
8840 {
8841 if(dir==up)
8842 {
8843 y=int32_t(y+7)&0xF0;
8844 }
8845
8846 if(dir==down)
8847 {
8848 y=int32_t(y+7)&0xF0;
8849 }
8850
8851 if(dir==left)
8852 {
8853 x=int32_t(x+7)&0xF0;
8854 }
8855
8856 if(dir==right)
8857 {
8858 x=int32_t(x+7)&0xF0;
8859 }
8860
8861 hs_fix=false;
8862 }
8863
8864 4732 }
8865
8866
2/2
✓ Branch 0 taken 370914 times.
✓ Branch 1 taken 6035587 times.
6406501 if(!get_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP))
8867 {
8868
2/2
✓ Branch 0 taken 3382 times.
✓ Branch 1 taken 6032205 times.
6035587 if(DrunkrLbtn())
8869 3382 selectNextBWpn(SEL_LEFT);
8870
2/2
✓ Branch 0 taken 6028495 times.
✓ Branch 1 taken 3710 times.
6032205 else if(DrunkrRbtn())
8871 3710 selectNextBWpn(SEL_RIGHT);
8872 6035587 }
8873
4/4
✓ Branch 0 taken 381005 times.
✓ Branch 1 taken 6025496 times.
✓ Branch 2 taken 370350 times.
✓ Branch 3 taken 10655 times.
6406501 if (get_bit(quest_rules, qr_SELECTAWPN) && get_bit(quest_rules, qr_USE_EX1_EX2_INVENTORYSWAP))
8874 {
8875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10655 times.
10655 if (rEx3btn())
8876 selectNextAWpn(SEL_LEFT);
8877
2/2
✓ Branch 0 taken 10654 times.
✓ Branch 1 taken 1 times.
10655 else if (rEx4btn())
8878 1 selectNextAWpn(SEL_RIGHT);
8879 10655 }
8880
8881
2/2
✓ Branch 0 taken 6406221 times.
✓ Branch 1 taken 280 times.
6406501 if(rPbtn())
8882 {
8883
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 277 times.
280 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
8884 277 onViewMap();
8885 280 }
8886
2/2
✓ Branch 0 taken 2708719 times.
✓ Branch 1 taken 6406501 times.
9115220 for(int32_t i=0; i<Lwpns.Count(); i++)
8887 {
8888 2708719 weapon *w = ((weapon*)Lwpns.spr(i));
8889
8890
6/6
✓ Branch 0 taken 2687806 times.
✓ Branch 1 taken 20913 times.
✓ Branch 2 taken 2394783 times.
✓ Branch 3 taken 293023 times.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 2394710 times.
2708719 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
8891 314009 addsparkle(i);
8892 2708719 }
8893
8894
1/2
✓ Branch 0 taken 6406501 times.
✗ Branch 1 not taken.
6406501 if(Lwpns.idCount(wPhantom))
8895 {
8896 addsparkle2(pDIVINEFIREROCKET,pDIVINEFIREROCKETTRAIL);
8897 addsparkle2(pDIVINEFIREROCKETRETURN,pDIVINEFIREROCKETTRAILRETURN);
8898 addsparkle2(pDIVINEPROTECTIONROCKET1,pDIVINEPROTECTIONROCKETTRAIL1);
8899 addsparkle2(pDIVINEPROTECTIONROCKET2,pDIVINEPROTECTIONROCKETTRAIL2);
8900 addsparkle2(pDIVINEPROTECTIONROCKETRETURN1,pDIVINEPROTECTIONROCKETTRAILRETURN1);
8901 addsparkle2(pDIVINEPROTECTIONROCKETRETURN2,pDIVINEPROTECTIONROCKETTRAILRETURN2);
8902 }
8903
8904 // Pay magic cost for Byrna beams
8905
8906 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
8907
2/2
✓ Branch 0 taken 6406428 times.
✓ Branch 1 taken 73 times.
6406501 if(Lwpns.idCount(wCByrna))
8908 {
8909 73 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
8910 73 int32_t itemid = ew->parentitem;
8911
8912
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
73 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
8913 {
8914 for(int32_t i=0; i<Lwpns.Count(); i++)
8915 {
8916 weapon *w = ((weapon*)Lwpns.spr(i));
8917
8918 if(w->id==wCByrna)
8919 {
8920 w->dead=1;
8921 }
8922
8923 }
8924 //kill the sound effect for the orbits -Z 14FEB2019
8925 stop_sfx(itemsbuf[itemid].usesound);
8926 }
8927 73 else paymagiccost(itemid);
8928 73 }
8929
8930
3/4
✓ Branch 0 taken 6402593 times.
✓ Branch 1 taken 3908 times.
✓ Branch 2 taken 6402593 times.
✗ Branch 3 not taken.
6406501 if(z==0&&fakez==0)
8931 {
8932 6402593 switchblock_z = 0;
8933
1/2
✓ Branch 0 taken 6402593 times.
✗ Branch 1 not taken.
6402593 if(switchblock_offset)
8934 {
8935 switchblock_offset=false;
8936 yofs += 8;
8937 }
8938 6402593 }
8939
2/2
✓ Branch 0 taken 250696 times.
✓ Branch 1 taken 6155805 times.
6406501 if(!isSideViewHero())
8940 {
8941 6155805 int32_t tx = x.getInt()+8,
8942 6155805 ty = y.getInt()+8;//(bigHitbox?8:12);
8943
4/4
✓ Branch 0 taken 6155558 times.
✓ Branch 1 taken 247 times.
✓ Branch 2 taken 214 times.
✓ Branch 3 taken 6155344 times.
6155805 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
8944 {
8945
2/2
✓ Branch 0 taken 6155344 times.
✓ Branch 1 taken 18466032 times.
24621376 for(int32_t q = 0; q < 3; ++q)
8946 {
8947
4/4
✓ Branch 0 taken 12310688 times.
✓ Branch 1 taken 6155344 times.
✓ Branch 2 taken 1609942 times.
✓ Branch 3 taken 10700746 times.
18466032 if(q && !tmpscr2[q-1].valid) continue;
8948 7765286 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
8949
3/4
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 7764319 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
7765286 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
8950 int32_t b = 1;
8951 if(tx&8) b <<= 2;
8952 if(ty&8) b <<= 1;
8953 b |= (b<<4); //check equivalent effect flag too
8954 if((cmb.walk&b)==b) //solid and effecting
8955 {
8956 if(z==0&&fakez==0)
8957 {
8958 if(cmb.usrflags&cflag10)
8959 {
8960 if(!switchblock_offset)
8961 {
8962 switchblock_offset=true;
8963 yofs -= 8;
8964 }
8965 }
8966 else
8967 {
8968 if(switchblock_offset)
8969 {
8970 switchblock_offset=false;
8971 yofs += 8;
8972 }
8973 }
8974 }
8975 if(cmb.attributes[2]>0 && switchblock_z>=0)
8976 {
8977 if(z==0&&fakez==0)
8978 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
8979 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
8980 {
8981 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
8982 }
8983 }
8984 else switchblock_z = -1;
8985 break;
8986 }
8987 }
8988 6155344 }
8989 6155805 }
8990 6406501 ClearhitHeroUIDs(); //clear them before we advance.
8991 6406501 checkhit();
8992
8993 6406501 bool forcedeath = dying_flags&DYING_FORCED;
8994 6406501 bool norev = (dying_flags&DYING_NOREV);
8995
4/6
✓ Branch 0 taken 6406501 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118 times.
✓ Branch 3 taken 6406383 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 118 times.
6406501 if(forcedeath || (game->get_life()<=0 && !immortal))
8996 {
8997
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(forcedeath)
8998 game->set_life(0);
8999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(!norev)
9000
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 30208 times.
30326 for(size_t slot = 0; slot < 256; ++slot)
9001 {
9002
1/2
✓ Branch 0 taken 30208 times.
✗ Branch 1 not taken.
30208 if(size_t bind = game->get_bottle_slot(slot))
9003 {
9004 bottletype const* bt = &QMisc.bottle_types[bind-1];
9005 if(!(bt->flags&BTFLAG_AUTOONDEATH))
9006 continue;
9007 word toFill[3] = { 0 };
9008 for(size_t q = 0; q < 3; ++q)
9009 {
9010 char c = bt->counter[q];
9011 if(c > -1)
9012 {
9013 if(bt->flags & (1<<q))
9014 {
9015 toFill[q] = (bt->amount[q]==100)
9016 ? game->get_maxcounter(c)
9017 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
9018 }
9019 else toFill[q] = bt->amount[q];
9020 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
9021 {
9022 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
9023 }
9024 }
9025 }
9026 if(bt->flags & BTFLAG_CURESWJINX)
9027 {
9028 swordclk = 0;
9029 verifyAWpn();
9030 }
9031 if(bt->flags & BTFLAG_CUREITJINX)
9032 itemclk = 0;
9033 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
9034 {
9035 int32_t itemid = find_bottle_for_slot(slot,true);
9036 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
9037 if(itemid > -1)
9038 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
9039 for(size_t q = 0; q < 20; ++q)
9040 do_death_refill_waitframe();
9041 double inc = max/60.0; //1 second
9042 double xtra[3]{ 0 };
9043 for(size_t q = 0; q < 60; ++q)
9044 {
9045 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
9046 sfx(QMisc.miscsfx[sfxREFILL]);
9047 for(size_t j = 0; j < 3; ++j)
9048 {
9049 xtra[j] += inc;
9050 word f = floor(xtra[j]);
9051 xtra[j] -= f;
9052 if(toFill[j] > f)
9053 {
9054 toFill[j] -= f;
9055 game->change_counter(f,bt->counter[j]);
9056 }
9057 else if(toFill[j])
9058 {
9059 game->change_counter(toFill[j],bt->counter[j]);
9060 toFill[j] = 0;
9061 }
9062 }
9063 do_death_refill_waitframe();
9064 }
9065 for(size_t j = 0; j < 3; ++j)
9066 {
9067 if(toFill[j])
9068 {
9069 game->change_counter(toFill[j],bt->counter[j]);
9070 toFill[j] = 0;
9071 }
9072 }
9073 for(size_t q = 0; q < 20; ++q)
9074 do_death_refill_waitframe();
9075 }
9076 game->set_bottle_slot(slot,bt->next_type);
9077 if(game->get_life() > 0)
9078 {
9079 dying_flags = 0;
9080 forcedeath = false;
9081 break; //Revived! Stop drinking things...
9082 }
9083 }
9084 30326 }
9085
9086
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 106 times.
118 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9087 {
9088
3/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
12 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9089 {
9090 // So scripts can have one frame to handle hp zero events
9091
3/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11 times.
12 if(norev || false == (last_hurrah = !last_hurrah))
9092 {
9093 1 dying_flags = 0;
9094 1 drunkclk=0;
9095 1 lstunclock = 0;
9096 1 is_conveyor_stunned = 0;
9097 1 FFCore.setHeroAction(dying);
9098 1 FFCore.deallocateAllArrays(ScriptType::Global, GLOBAL_SCRIPT_GAME);
9099 1 FFCore.deallocateAllArrays(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
9100 1 ALLOFF(true,true);
9101 1 GameFlags |= GAMEFLAG_NO_F6;
9102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!debug_enabled)
9103 {
9104 1 Paused=false;
9105 1 }
9106
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9107 {
9108 FFCore.runOnDeathEngine();
9109 FFCore.deallocateAllArrays(ScriptType::Player, SCRIPT_PLAYER_DEATH);
9110 }
9111 1 Playing = false;
9112 1 heroDeathAnimation();
9113
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9114 {
9115 1 Playing = true;
9116 1 FFCore.runOnDeathEngine();
9117 1 FFCore.deallocateAllArrays(ScriptType::Player, SCRIPT_PLAYER_DEATH);
9118 1 Playing = false;
9119 1 }
9120 1 GameFlags &= ~GAMEFLAG_NO_F6;
9121 1 ALLOFF(true,true);
9122 1 return true;
9123 }
9124 11 }
9125 11 }
9126 else //2.50.x
9127 {
9128 // So scripts can have one frame to handle hp zero events
9129
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 53 times.
106 if(false == (last_hurrah = !last_hurrah))
9130 {
9131 53 drunkclk=0;
9132 53 heroDeathAnimation();
9133
9134 53 return true;
9135 }
9136 }
9137 64 }
9138 6406383 else last_hurrah=false;
9139
9140
2/2
✓ Branch 0 taken 6373998 times.
✓ Branch 1 taken 32449 times.
6406447 if(swordclk>0)
9141 {
9142 32449 --swordclk;
9143
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 32294 times.
32449 if(!swordclk) verifyAWpn();
9144 32449 }
9145
2/2
✓ Branch 0 taken 6402389 times.
✓ Branch 1 taken 4058 times.
6406447 if(itemclk>0)
9146 4058 --itemclk;
9147
1/2
✓ Branch 0 taken 6406447 times.
✗ Branch 1 not taken.
6406447 if(shieldjinxclk>0)
9148 --shieldjinxclk;
9149
9150
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 6406155 times.
6406447 if(inwallm)
9151 {
9152 292 attackclk=0;
9153 292 herostep();
9154
9155
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(CarryHero()==false)
9156 3 restart_level();
9157
9158 292 solid_update(false);
9159 292 return false;
9160 }
9161
9162
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6406154 times.
6406155 if(ewind_restart)
9163 {
9164 1 attackclk=0;
9165 1 restart_level();
9166 1 xofs=0;
9167 1 action=none; FFCore.setHeroAction(none);
9168 1 ewind_restart=false;
9169 1 solid_update(false);
9170 1 return false;
9171 }
9172
9173
2/2
✓ Branch 0 taken 6400031 times.
✓ Branch 1 taken 6123 times.
6406154 if(hopclk)
9174 {
9175 6123 action=hopping; FFCore.setHeroAction(hopping);
9176 6123 }
9177
2/2
✓ Branch 0 taken 6405664 times.
✓ Branch 1 taken 490 times.
6406154 if(fallclk)
9178 {
9179 490 action=falling; FFCore.setHeroAction(falling);
9180 490 }
9181
9182 6406154 handle_passive_buttons();
9183
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 6405938 times.
6406154 if(liftclk)
9184 {
9185
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(lift_wpn)
9186 {
9187 216 action=lifting; FFCore.setHeroAction(lifting);
9188 216 }
9189 else
9190 {
9191 liftclk = 0;
9192 tliftclk = 0;
9193 }
9194 216 }
9195
2/2
✓ Branch 0 taken 877 times.
✓ Branch 1 taken 6405061 times.
6405938 else if(lift_wpn)
9196 {
9197 877 handle_lift(false);
9198 877 }
9199
9200
9201 // get user input or do other animation
9202 6406154 freeze_guys=false; // reset this flag, set it again if holding
9203
9204
14/16
✓ Branch 0 taken 6364646 times.
✓ Branch 1 taken 41508 times.
✓ Branch 2 taken 6351252 times.
✓ Branch 3 taken 13394 times.
✓ Branch 4 taken 6350602 times.
✓ Branch 5 taken 650 times.
✓ Branch 6 taken 6350472 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 6350472 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6350472 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6334111 times.
✓ Branch 13 taken 16361 times.
✓ Branch 14 taken 6334089 times.
✓ Branch 15 taken 22 times.
6406154 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9205 {
9206 22 holdclk=0;
9207 22 }
9208
9209 6406154 active_shield_id = refreshActiveShield();
9210 6406154 bool sh = active_shield_id > -1;
9211 6406154 itemdata const& shield = itemsbuf[active_shield_id];
9212 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9213 6406154 shield_forcedir = -1;
9214
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6406154 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6406154 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9215 {
9216 shield_forcedir = dir;
9217 }
9218
1/2
✓ Branch 0 taken 6406154 times.
✗ Branch 1 not taken.
6406154 if(sh != shield_active) //Toggle active shield on/off
9219 {
9220 shield_active = sh;
9221 if(sh) //Toggle active shield on
9222 {
9223 sfx(shield.usesound2); //'Activate' sfx
9224 }
9225 }
9226
9227 6406154 bool isthissolid = false;
9228
11/12
✓ Branch 0 taken 64741 times.
✓ Branch 1 taken 780 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 104764 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 54902 times.
✓ Branch 6 taken 6116292 times.
✓ Branch 7 taken 47503 times.
✓ Branch 8 taken 490 times.
✓ Branch 9 taken 6123 times.
✓ Branch 10 taken 9767 times.
✓ Branch 11 taken 216 times.
6406154 switch(action)
9229 {
9230 case gothit:
9231
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 1423 times.
47503 if(attackclk)
9232
2/2
✓ Branch 0 taken 1235 times.
✓ Branch 1 taken 188 times.
1611 if(!doattack())
9233 {
9234 188 attackclk=spins=0;
9235 188 tapping=false;
9236 188 }
9237
9238 47503 break;
9239
9240 case drowning:
9241 case lavadrowning:
9242 case sidedrowning:
9243 {
9244 576 herostep(); // maybe this line should be elsewhere?
9245
9246 //!DROWN
9247 // Helpful comment to find drowning -Dimi
9248
9249 576 drop_liftwpn();
9250
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 9 times.
576 if(--drownclk==0)
9251 {
9252 9 action=none; FFCore.setHeroAction(none);
9253
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 int32_t water = drownCombo ? drownCombo : iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9254
9255 9 std::vector<int32_t> &ev = FFCore.eventData;
9256 9 ev.clear();
9257 9 ev.push_back(water*10000);
9258
9259 9 throwGenScriptEvent(GENSCR_EVENT_PLAYER_DROWN);
9260 9 water = ev[0]/10000;
9261 9 newcombo const& watercmb = combobuf[water];
9262
9263 9 int32_t damage = 4;
9264
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if (watercmb.type == cWATER)
9265 8 damage = watercmb.attributes[0]/10000L;
9266 1 else water = 0;
9267
9268
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if(cheat_superman && damage > 0)
9269 damage = 0;
9270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(damage)
9271 9 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9272 9 drownCombo = 0;
9273 9 go_respawn_point();
9274 9 hclk=48;
9275 9 }
9276
9277 576 break;
9278 }
9279 case falling:
9280 {
9281 490 herostep();
9282 490 pitfall();
9283 490 break;
9284 }
9285 case freeze:
9286 case sideswimfreeze:
9287 case scrolling:
9288 104764 break;
9289
9290 case casting:
9291 case sideswimcasting:
9292 {
9293 if(magicitem==-1)
9294 {
9295 action=none; FFCore.setHeroAction(none);
9296 }
9297
9298 break;
9299 }
9300 case landhold1:
9301 case landhold2:
9302 {
9303
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 54480 times.
54902 if(--holdclk <= 0)
9304 {
9305 //restart music
9306
4/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 359 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 28 times.
422 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9307 28 playLevelMusic();
9308
9309 422 action=none; FFCore.setHeroAction(none);
9310 422 post_item_collect();
9311 422 }
9312 else
9313 54480 freeze_guys=true;
9314
9315 54902 break;
9316 }
9317 case waterhold1:
9318 case waterhold2:
9319 case sidewaterhold1:
9320 case sidewaterhold2:
9321 {
9322 780 diveclk=0;
9323
9324
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 774 times.
780 if(--holdclk <= 0)
9325 {
9326 //restart music
9327
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9328 playLevelMusic();
9329
9330 6 SetSwim();
9331 6 post_item_collect();
9332 6 }
9333 else
9334 774 freeze_guys=true;
9335
9336 780 break;
9337 }
9338 case hopping:
9339 {
9340
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6123 if(DRIEDLAKE)
9341 {
9342 action=none; FFCore.setHeroAction(none);
9343 hopclk = 0;
9344 diveclk = 0;
9345 break;
9346 }
9347
9348 6123 do_hopping();
9349 6123 break;
9350 }
9351 case inwind:
9352 {
9353 9767 int32_t i=Lwpns.idFirst(wWind);
9354
9355
2/2
✓ Branch 0 taken 9634 times.
✓ Branch 1 taken 133 times.
9767 if(i<0)
9356 {
9357 133 bool exit=false;
9358
9359
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 67 times.
133 if(whirlwind==255)
9360 {
9361 66 exit=true;
9362 66 }
9363
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(y<=0 && dir==up) y=-1;
9364
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(y>=160 && dir==down) y=161;
9365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(x<=0 && dir==left) x=-1;
9366
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
67 else if(x>=240 && dir==right) x=241;
9367 else exit=true;
9368
9369
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 66 times.
133 if(exit)
9370 {
9371 66 action=none; FFCore.setHeroAction(none);
9372 66 xofs=0;
9373 66 whirlwind=0;
9374 66 lstep=0;
9375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if ( dontdraw < 2 ) dontdraw=0;
9376 66 set_respawn_point();
9377 66 }
9378 133 }
9379 /*
9380 else if (((weapon*)Lwpns.spr(i))->dead==1)
9381 {
9382 whirlwind=255;
9383 }
9384 */
9385 else
9386 {
9387 9634 x=Lwpns.spr(i)->x;
9388 9634 y=Lwpns.spr(i)->y;
9389 9634 dir=Lwpns.spr(i)->dir;
9390 }
9391 }
9392 9767 break;
9393 case lifting:
9394 216 handle_lift();
9395 216 break;
9396
9397 case sideswimming:
9398 case sideswimattacking:
9399 case sideswimhit:
9400 case swimhit:
9401 case swimming:
9402 {
9403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64741 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64741 if(DRIEDLAKE)
9404 {
9405 action=none; FFCore.setHeroAction(none);
9406 hopclk=0;
9407 break;
9408 }
9409
9410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64741 times.
64741 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9411
9412
4/4
✓ Branch 0 taken 32339 times.
✓ Branch 1 taken 32402 times.
✓ Branch 2 taken 259 times.
✓ Branch 3 taken 32080 times.
64741 if((frame&1) && !shouldbreak)
9413 32080 herostep();
9414
9415
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 64741 times.
✓ Branch 2 taken 64741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2282 times.
✓ Branch 5 taken 62459 times.
67023 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9416
4/6
✓ Branch 0 taken 62459 times.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
64741 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
9417
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
2282 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9418
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
64741 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
9419
4/4
✓ Branch 0 taken 63474 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 63474 times.
✓ Branch 3 taken 1267 times.
64741 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9420 {
9421
4/4
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1255 times.
✓ Branch 3 taken 1 times.
2523 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
9422
4/4
✓ Branch 0 taken 1262 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1256 times.
✓ Branch 3 taken 6 times.
1264 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
9423 {
9424 12 hopclk=0;
9425 12 diveclk=0;
9426
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9427 else {action=attacking; FFCore.setHeroAction(attacking);}
9428 12 hopdir=-1;
9429 12 }
9430 1267 }
9431
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 64214 times.
64741 if (shouldbreak) break;
9432
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 64202 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
64214 if (action == swimming || action == sideswimming || action == sideswimattacking)
9433 {
9434 64202 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64202 times.
64202 if (combobuf[watercheck].usrflags&cflag2)
9436 {
9437 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9438 {
9439 onpassivedmg = true;
9440 if (damageovertimeclk == 0)
9441 {
9442 int32_t curhp = game->get_life();
9443 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9444 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9445 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9446 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9447 {
9448 hclk = 48;
9449 hitdir = -1;
9450 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9451 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9452 }
9453 }
9454 if (combobuf[watercheck].attribytes[1] > 0)
9455 {
9456 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9457 else --damageovertimeclk;
9458 }
9459 else damageovertimeclk = 0;
9460 }
9461 else damageovertimeclk = 0;
9462 }
9463 64202 else damageovertimeclk = 0;
9464 //combobuf[watercheck].attributes[0]
9465 64202 }
9466
9467 64214 }
9468 [[fallthrough]];
9469 default:
9470 // call the main movement routine
9471
1/2
✓ Branch 0 taken 6180506 times.
✗ Branch 1 not taken.
6180506 if(get_bit(quest_rules,qr_NEW_HERO_MOVEMENT2))
9472 {
9473 if(premove())
9474 movehero();
9475 }
9476 6180506 else moveheroOld();
9477 6180506 }
9478
9479
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6406154 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6406154 if(shield_forcedir > -1 && action != rafting)
9480 dir = shield_forcedir;
9481
9482
2/2
✓ Branch 0 taken 6390100 times.
✓ Branch 1 taken 16054 times.
6406154 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
9483 16054 set_respawn_point(false); //Keep the 'last safe location' updated!
9484
9485 // check for ladder removal
9486
2/2
✓ Branch 0 taken 700648 times.
✓ Branch 1 taken 5705506 times.
6406154 if(diagonalMovement)
9487 {
9488
2/2
✓ Branch 0 taken 700612 times.
✓ Branch 1 taken 36 times.
700648 if(ladderx+laddery)
9489 {
9490
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(ladderdir==up)
9491 {
9492 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9493 {
9494 reset_ladder();
9495 }
9496 }
9497 else
9498 {
9499
9/10
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 33 times.
36 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9500 {
9501 3 reset_ladder();
9502 3 }
9503 }
9504 36 }
9505 700648 }
9506 else
9507 {
9508
4/4
✓ Branch 0 taken 224933 times.
✓ Branch 1 taken 5480573 times.
✓ Branch 2 taken 121768 times.
✓ Branch 3 taken 103165 times.
5705506 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9509 {
9510 5602341 reset_ladder();
9511 5602341 }
9512 }
9513
9514
2/2
✓ Branch 0 taken 899 times.
✓ Branch 1 taken 6405255 times.
6406154 if(ilswim)
9515 899 landswim++;
9516 6405255 else landswim=0;
9517
9518
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6406152 times.
6406154 if(hopclk!=0xFF) ilswim=false;
9519
9520
3/4
✓ Branch 0 taken 13102 times.
✓ Branch 1 taken 6393052 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13102 times.
6406154 if((!loaded_guys) && (frame - newscr_clk >= 1))
9521 {
9522
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13089 times.
13102 if(tmpscr->room==rGANON)
9523 {
9524 13 ganon_intro();
9525 13 }
9526 else
9527 {
9528 13089 loadguys();
9529 }
9530 13102 }
9531
9532
2/2
✓ Branch 0 taken 13667 times.
✓ Branch 1 taken 6392487 times.
6406154 if(frame - newscr_clk >= 2)
9533 {
9534 6392487 loadenemies();
9535 6392487 }
9536
9537 // check lots of other things
9538 6406154 checkscroll();
9539
9540
6/8
✓ Branch 0 taken 6396452 times.
✓ Branch 1 taken 9702 times.
✓ Branch 2 taken 6395885 times.
✓ Branch 3 taken 567 times.
✓ Branch 4 taken 6395885 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6395885 times.
6406154 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9541 {
9542 6395885 checkspecial();
9543 6395885 checkitems();
9544 6395885 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9545
2/2
✓ Branch 0 taken 16618 times.
✓ Branch 1 taken 6379267 times.
6395885 if(get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
9546 {
9547 6379267 oldchecklockblock();
9548 6379267 oldcheckbosslockblock();
9549 6379267 }
9550
2/2
✓ Branch 0 taken 146285 times.
✓ Branch 1 taken 6249600 times.
6395885 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
9551 {
9552 6249600 oldcheckchest(cCHEST);
9553 6249600 oldcheckchest(cLOCKEDCHEST);
9554 6249600 oldcheckchest(cBOSSCHEST);
9555 6249600 }
9556 6395885 checkpushblock();
9557 6395885 checkswordtap();
9558
9559
2/2
✓ Branch 0 taken 4732 times.
✓ Branch 1 taken 6391153 times.
6395885 if(hookshot_frozen==false)
9560 {
9561 6391153 checkspecial2(&lsave);
9562 6391153 }
9563
9564
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 6395876 times.
6395885 if(action==won)
9565 {
9566 9 return true;
9567 }
9568 6395876 }
9569
9570 // Somehow Hero was displaced from the fairy flag...
9571
3/6
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 6389784 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16361 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6406145 if(fairyclk && action != freeze && action != sideswimfreeze)
9572 {
9573 fairyclk = holdclk = refill_why = 0;
9574 }
9575
9576
4/4
✓ Branch 0 taken 6406143 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 9978 times.
✓ Branch 3 taken 6396165 times.
6406145 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
9577 {
9578 9978 tmpscr->timedwarptics--;
9579
9580
2/2
✓ Branch 0 taken 9938 times.
✓ Branch 1 taken 40 times.
9978 if(tmpscr->timedwarptics==0)
9581 {
9582 40 activated_timed_warp=true;
9583
9584
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 3 times.
40 if(tmpscr->flags4 & fTIMEDDIRECT)
9585 {
9586 3 didpit=true;
9587 3 pitx=x;
9588 3 pity=y;
9589 3 }
9590
9591 40 int32_t index2 = 0;
9592
9593
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
9594
9595 40 sdir = dir;
9596 40 dowarp(1,index2);
9597 40 }
9598 9978 }
9599
9600 6406145 bool awarp = false;
9601 //!DIMI: Global Combo Effects (AUTO STUFF)
9602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6406145 times.
6406145 for(auto& p : slopes)
9603 {
9604 slope_object& s = p.second;
9605 s.updateslope(); //sets old x/y poses
9606 }
9607
2/2
✓ Branch 0 taken 6406144 times.
✓ Branch 1 taken 1127481142 times.
1133887286 for(int32_t i=0; i<176; ++i)
9608 {
9609
2/2
✓ Branch 0 taken 2628032 times.
✓ Branch 1 taken 4517808661 times.
4520436693 for(int32_t layer=0; layer<7; ++layer)
9610 {
9611
2/2
✓ Branch 0 taken 3390327519 times.
✓ Branch 1 taken 1127481142 times.
4517808661 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
9612 4517808661 newcombo const& cmb = combobuf[cid];
9613
9614
2/2
✓ Branch 0 taken 18396224 times.
✓ Branch 1 taken 4499412437 times.
4517808661 if(!get_bit(quest_rules,qr_AUTOCOMBO_ANY_LAYER))
9615 {
9616
2/2
✓ Branch 0 taken 1124853109 times.
✓ Branch 1 taken 3374559328 times.
4499412437 if(layer > 2) break;
9617
4/4
✓ Branch 0 taken 1124853109 times.
✓ Branch 1 taken 2249706219 times.
✓ Branch 2 taken 23206656 times.
✓ Branch 3 taken 1101646453 times.
3374559328 if (layer == 1 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_1)) continue;
9618
4/4
✓ Branch 0 taken 1124853109 times.
✓ Branch 1 taken 1148059766 times.
✓ Branch 2 taken 23206656 times.
✓ Branch 3 taken 1101646453 times.
2272912875 if (layer == 2 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_2)) continue;
9619 1171266422 }
9620 1189662646 int32_t ind=0;
9621
9622 //AUTOMATIC TRIGGER CODE
9623
2/2
✓ Branch 0 taken 1189648560 times.
✓ Branch 1 taken 14086 times.
1189662646 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9624 {
9625 14086 do_trigger_combo(layer, i);
9626 14086 }
9627
9628 //AUTO WARP CODE
9629
2/2
✓ Branch 0 taken 19463 times.
✓ Branch 1 taken 1189643183 times.
1189662646 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9630 {
9631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1189643183 times.
1189643183 if(cmb.type==cAWARPA)
9632 {
9633 awarp=true;
9634 ind=0;
9635 }
9636
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1189643182 times.
1189643183 else if(cmb.type==cAWARPB)
9637 {
9638 1 awarp=true;
9639 1 ind=1;
9640 1 }
9641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1189643182 times.
1189643182 else if(cmb.type==cAWARPC)
9642 {
9643 awarp=true;
9644 ind=2;
9645 }
9646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1189643182 times.
1189643182 else if(cmb.type==cAWARPD)
9647 {
9648 awarp=true;
9649 ind=3;
9650 }
9651
1/2
✓ Branch 0 taken 1189643182 times.
✗ Branch 1 not taken.
1189643182 else if(cmb.type==cAWARPR)
9652 {
9653 awarp=true;
9654 ind=zc_oldrand()%4;
9655 }
9656 1189643183 }
9657
2/2
✓ Branch 0 taken 1189662645 times.
✓ Branch 1 taken 1 times.
1189662646 if(awarp)
9658 {
9659
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags5&fDIRECTAWARP)
9660 {
9661 didpit=true;
9662 pitx=x;
9663 pity=y;
9664 }
9665
9666 1 sdir = dir;
9667 1 dowarp(1,ind);
9668 1 break;
9669 }
9670 1189662645 }
9671
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1127481141 times.
1127481142 if(awarp) break;
9672 1127481141 }
9673
9674 6406145 awarp=false;
9675
9676 6406145 word c = tmpscr->numFFC();
9677
2/2
✓ Branch 0 taken 6406128 times.
✓ Branch 1 taken 200959690 times.
207365818 for(word i=0; i<c; i++)
9678 {
9679 200959690 int32_t ind=0;
9680
9681 200959690 newcombo const& cmb = combobuf[tmpscr->ffcs[i].getData()];
9682
9683
1/2
✓ Branch 0 taken 200959690 times.
✗ Branch 1 not taken.
200959690 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9684 {
9685 do_trigger_combo_ffc(i);
9686 }
9687
9688
2/2
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 200955782 times.
200959690 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9689 {
9690
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 200955776 times.
200955782 if(cmb.type==cAWARPA)
9691 {
9692 6 awarp=true;
9693 6 ind=0;
9694 6 }
9695
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 200955769 times.
200955776 else if(cmb.type==cAWARPB)
9696 {
9697 7 awarp=true;
9698 7 ind=1;
9699 7 }
9700
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 200955768 times.
200955769 else if(cmb.type==cAWARPC)
9701 {
9702 1 awarp=true;
9703 1 ind=2;
9704 1 }
9705
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 200955765 times.
200955768 else if(cmb.type==cAWARPD)
9706 {
9707 3 awarp=true;
9708 3 ind=3;
9709 3 }
9710
1/2
✓ Branch 0 taken 200955765 times.
✗ Branch 1 not taken.
200955765 else if(cmb.type==cAWARPR)
9711 {
9712 awarp=true;
9713 ind=zc_oldrand()%4;
9714 }
9715 200955782 }
9716
9717
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 200959673 times.
200959690 if(awarp)
9718 {
9719
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tmpscr->flags5&fDIRECTAWARP)
9720 {
9721 didpit=true;
9722 pitx=x;
9723 pity=y;
9724 }
9725
9726 17 sdir = dir;
9727 17 dowarp(1,ind);
9728 17 break;
9729 }
9730 200959673 }
9731 6406145 zfix dx, dy;
9732
5/8
✓ Branch 0 taken 250687 times.
✓ Branch 1 taken 6155458 times.
✓ Branch 2 taken 124591 times.
✓ Branch 3 taken 126096 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 124591 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6406145 if (sideview_mode() && !on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && on_sideview_solid_oldpos(x, y,old_x,old_y, false, 2) && !toogam)
9733 {
9734 if (slide_slope(this, dx, dy, slopeid))
9735 {
9736 onplatid = 5;
9737 if (dx || dy) push_move(dx, dy);
9738 }
9739 }
9740
1/2
✓ Branch 0 taken 6406145 times.
✗ Branch 1 not taken.
6406145 if (onplatid <= 0) slopeid = 0;
9741 else --onplatid;
9742
2/2
✓ Branch 0 taken 4947543 times.
✓ Branch 1 taken 1458602 times.
6406145 bool onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9743
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6406145 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6406145 times.
6406145 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
9744 {
9745 if (check_slope(this, true) && !toogam)
9746 {
9747 slope_info const& s = get_slope(this, true).get_info();
9748 bool staircheck = false;
9749 if (s.slope() != slopeid && slopeid) staircheck = true;
9750 if (onplatform) staircheck = true;
9751 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
9752
9753 if (dx || dy)
9754 {
9755 int32_t pushret = push_move(dx,dy);
9756 onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9757 if (s.slope() != slopeid && slopeid) staircheck = true;
9758 if (onplatform) staircheck = true;
9759 if(sideview_mode() && slopeid)
9760 onplatid = 5;
9761 if (pushret == 1)
9762 {
9763 dx = -1;
9764 dy = 0;
9765 slope_push_int(s, this, dx, dy, staircheck);
9766 push_move(dx,dy);
9767 }
9768 if (pushret == 2)
9769 {
9770 dx = 0;
9771 dy = -1;
9772 slope_push_int(s, this, dx, dy, staircheck);
9773 push_move(dx,dy);
9774 }
9775 }
9776 }
9777 }
9778
9779
2/2
✓ Branch 0 taken 6405940 times.
✓ Branch 1 taken 205 times.
6406145 if(ffwarp)
9780 {
9781
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 126 times.
205 if(ffpit)
9782 {
9783 126 ffpit=false;
9784 126 didpit=true;
9785 126 pitx=x;
9786 126 pity=y;
9787 126 }
9788
9789 205 ffwarp=false;
9790 205 dowarp(1,0);
9791 205 }
9792
9793 //Hero->WarpEx
9794
2/2
✓ Branch 0 taken 6406129 times.
✓ Branch 1 taken 16 times.
6406145 if ( FFCore.warpex[wexActive] )
9795 {
9796 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
9797 16 FFCore.warpex[wexActive] = 0;
9798 16 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
9799
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 16 times.
160 for ( int32_t q = 0; q < wexActive; q++ )
9800 {
9801 144 temp_warpex[q] = FFCore.warpex[q];
9802 144 FFCore.warpex[q] = 0;
9803 144 }
9804 32 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
9805 16 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
9806 16 }
9807
9808 // walk through bombed doors and fake walls
9809 6406145 bool walk=false;
9810 6406145 int32_t dtype=dBOMBED;
9811
9812
2/2
✓ Branch 0 taken 6230093 times.
✓ Branch 1 taken 176052 times.
6406145 if(pushing>=24) dtype=dWALK;
9813
9814
16/18
✓ Branch 0 taken 3659598 times.
✓ Branch 1 taken 2746547 times.
✓ Branch 2 taken 3619787 times.
✓ Branch 3 taken 39811 times.
✓ Branch 4 taken 3619787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3614419 times.
✓ Branch 7 taken 5368 times.
✓ Branch 8 taken 3611844 times.
✓ Branch 9 taken 2575 times.
✓ Branch 10 taken 3611193 times.
✓ Branch 11 taken 651 times.
✓ Branch 12 taken 3601342 times.
✓ Branch 13 taken 9851 times.
✓ Branch 14 taken 3601342 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 101062 times.
✓ Branch 17 taken 3702404 times.
6406145 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
9815 {
9816
16/18
✓ Branch 0 taken 100684 times.
✓ Branch 1 taken 3601720 times.
✓ Branch 2 taken 590976 times.
✓ Branch 3 taken 3010744 times.
✓ Branch 4 taken 590861 times.
✓ Branch 5 taken 115 times.
✓ Branch 6 taken 590861 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 590861 times.
✓ Branch 10 taken 109 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 130662 times.
✓ Branch 13 taken 460314 times.
✓ Branch 14 taken 38152 times.
✓ Branch 15 taken 92510 times.
✓ Branch 16 taken 38016 times.
✓ Branch 17 taken 136 times.
3702404 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y<=32 && tmpscr->door[0]==dtype)
9817 {
9818 136 walk=true;
9819 136 dir=up;
9820 136 }
9821
9822
16/18
✓ Branch 0 taken 100684 times.
✓ Branch 1 taken 3601720 times.
✓ Branch 2 taken 388941 times.
✓ Branch 3 taken 3212779 times.
✓ Branch 4 taken 489459 times.
✓ Branch 5 taken 166 times.
✓ Branch 6 taken 489459 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 489459 times.
✓ Branch 10 taken 74 times.
✓ Branch 11 taken 92 times.
✓ Branch 12 taken 75655 times.
✓ Branch 13 taken 413970 times.
✓ Branch 14 taken 22498 times.
✓ Branch 15 taken 53157 times.
✓ Branch 16 taken 22383 times.
✓ Branch 17 taken 115 times.
3702404 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y>=128 && tmpscr->door[1]==dtype)
9823 {
9824 115 walk=true;
9825 115 dir=down;
9826 115 }
9827
9828
11/16
✓ Branch 0 taken 100684 times.
✓ Branch 1 taken 3601720 times.
✓ Branch 2 taken 59050 times.
✓ Branch 3 taken 3542670 times.
✓ Branch 4 taken 58672 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58672 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 58672 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 26325 times.
✓ Branch 13 taken 32347 times.
✓ Branch 14 taken 26224 times.
✓ Branch 15 taken 101 times.
3702404 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[2]==dtype)
9829 {
9830 101 walk=true;
9831 101 dir=left;
9832 101 }
9833
9834
11/16
✓ Branch 0 taken 3500658 times.
✓ Branch 1 taken 100684 times.
✓ Branch 2 taken 52160 times.
✓ Branch 3 taken 3448498 times.
✓ Branch 4 taken 72644 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 72644 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 72644 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 35229 times.
✓ Branch 13 taken 37415 times.
✓ Branch 14 taken 35114 times.
✓ Branch 15 taken 115 times.
3601342 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[3]==dtype)
9835 {
9836 115 walk=true;
9837 115 dir=right;
9838 115 }
9839 3521142 }
9840
9841
2/2
✓ Branch 0 taken 6426540 times.
✓ Branch 1 taken 467 times.
6427007 if(walk)
9842 {
9843 467 hclk=0;
9844 467 drawguys=false;
9845
9846
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 172 times.
467 if(dtype==dWALK)
9847 {
9848 172 sfx(tmpscr->secretsfx);
9849 172 }
9850
9851 467 action=none; FFCore.setHeroAction(none);
9852 467 attackclk = 0;
9853 467 stepforward(29, true);
9854 467 action=scrolling; FFCore.setHeroAction(scrolling);
9855 467 pushing=false;
9856 467 }
9857
9858
4/6
✓ Branch 0 taken 107979 times.
✓ Branch 1 taken 6319028 times.
✓ Branch 2 taken 107979 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 107979 times.
6427007 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
9859 {
9860
1/2
✓ Branch 0 taken 107979 times.
✗ Branch 1 not taken.
107979 if(heart_beep)
9861 {
9862 107979 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9863 107979 }
9864 else
9865 {
9866 if ( heart_beep_timer == -1 )
9867 {
9868 heart_beep_timer = 70;
9869 }
9870
9871 if ( heart_beep_timer > 0 )
9872 {
9873 --heart_beep_timer;
9874 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9875 }
9876 else
9877 {
9878 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9879 }
9880 }
9881 107979 }
9882 else
9883 {
9884
2/2
✓ Branch 0 taken 20864 times.
✓ Branch 1 taken 6298164 times.
6319028 if ( heart_beep_timer > -2 )
9885 {
9886 6298164 heart_beep_timer = -1;
9887 6298164 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9888 6298164 }
9889 }
9890
9891
2/2
✓ Branch 0 taken 6426242 times.
✓ Branch 1 taken 765 times.
6427007 if(rSbtn())
9892 {
9893 765 int32_t tmp_subscr_clk = frame;
9894
9895 765 int32_t save_type = 0;
9896
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
765 switch(lsave)
9897 {
9898 case 0:
9899 {
9900
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 716 times.
757 if( FFCore.runActiveSubscreenScriptEngine() )
9901 {
9902 41 break;
9903 }
9904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 else if ( !stopSubscreenFalling() )
9905 {
9906 716 conveyclk=3;
9907 716 dosubscr(&QMisc);
9908 716 newscr_clk += frame - tmp_subscr_clk;
9909 716 }
9910 716 break;
9911 }
9912
9913
9914 case 2:
9915 save_type = 1;
9916 [[fallthrough]];
9917 case 1:
9918
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
9919 7 trigger_save(combobuf[last_savepoint_id]);
9920 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
9921 7 break;
9922 }
9923 765 }
9924
9925
2/2
✓ Branch 0 taken 354224 times.
✓ Branch 1 taken 6072781 times.
6427005 if (!checkstab() )
9926 {
9927 /*
9928 for(int32_t q=0; q<176; q++)
9929 {
9930 set_bit(screengrid,q,0);
9931 }
9932
9933 for(int32_t q=0; q<MAXFFCS; q++)
9934 set_bit(ffcgrid, q, 0);
9935 */
9936 6072781 }
9937
9938 6427005 check_conveyor();
9939 6427005 PhantomsCleanup();
9940 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
9941
2/2
✓ Branch 0 taken 6361221 times.
✓ Branch 1 taken 65784 times.
6427005 if(attack==wHammer)
9942 {
9943
6/8
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 65043 times.
✓ Branch 2 taken 741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 741 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 739 times.
65784 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
9944 {
9945
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 162 times.
✓ Branch 3 taken 213 times.
✓ Branch 4 taken 247 times.
739 switch(dir) //Hero's dir
9946 {
9947 case up:
9948
5/10
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 117 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 117 times.
✗ Branch 9 not taken.
117 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
9949 117 break;
9950
9951 case down:
9952
5/10
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 162 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
9953 162 break;
9954
9955 case left:
9956
5/10
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 213 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 213 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 213 times.
✗ Branch 9 not taken.
213 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
9957 213 break;
9958
9959 case right:
9960
5/10
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 247 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 247 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 247 times.
✗ Branch 9 not taken.
247 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
9961 247 break;
9962 }
9963
9964 739 }
9965 65784 }
9966
9967 6427005 handleSpotlights();
9968
9969
1/2
✓ Branch 0 taken 6427005 times.
✗ Branch 1 not taken.
6427005 if(getOnSideviewLadder())
9970 {
9971 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
9972 {
9973 setOnSideviewLadder(false);
9974 }
9975 else if(CANFORCEFACEUP)
9976 {
9977 setDir(up);
9978 }
9979 }
9980
2/2
✓ Branch 0 taken 6211346 times.
✓ Branch 1 taken 215659 times.
6427005 if (justmoved > 0) --justmoved;
9981
9982 6427005 return false;
9983 6427361 }
9984
9985 bool HeroClass::push_pixel(zfix dx, zfix dy)
9986 {
9987 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
9988 if(dx && dy)
9989 {
9990 bool r = push_pixel(0,dy);
9991 bool r2 = push_pixel(dx,0);
9992 return r && r2;
9993 }
9994 if(dx < 0)
9995 {
9996 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
9997 || solpush_walkflag(x+dx,y+8,1,this)
9998 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
9999 {
10000 x += dx;
10001 return true;
10002 }
10003 return false;
10004 }
10005 else if(dx > 0)
10006 {
10007 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
10008 || solpush_walkflag(x+15+dx,y+8,1,this)
10009 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
10010 {
10011 x += dx;
10012 return true;
10013 }
10014 return false;
10015 }
10016 else if(dy < 0)
10017 {
10018 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
10019 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
10020 {
10021 y += dy;
10022 return true;
10023 }
10024 return false;
10025 }
10026 else if(dy > 0)
10027 {
10028 if(!(solpush_walkflag(x,y+15+dy,2,this)
10029 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
10030 {
10031 y += dy;
10032 return true;
10033 }
10034 return false;
10035 }
10036 return false;
10037 }
10038 int32_t HeroClass::push_move(zfix dx, zfix dy)
10039 {
10040 int32_t ret = 0;
10041 while(dx || dy)
10042 {
10043 if(check_pitslide() != -1)
10044 break;
10045 if(dy)
10046 {
10047 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
10048 dy -= cy;
10049 if(!push_pixel(0,cy))
10050 {
10051 dy = 0;
10052 ret |= 2;
10053 }
10054 }
10055 if(dx)
10056 {
10057 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
10058 dx -= cx;
10059 if(!push_pixel(cx,0))
10060 {
10061 dx = 0;
10062 ret |= 1;
10063 }
10064 }
10065 }
10066 return ret;
10067 }
10068
10069 6406435 bool HeroClass::setSolid(bool set)
10070 {
10071
1/2
✓ Branch 0 taken 6406435 times.
✗ Branch 1 not taken.
6406435 bool actual = set && !toogam; //not solid when noclipping
10072 6406435 bool ret = solid_object::setSolid(actual);
10073 6406435 solid = set;
10074 6406435 return ret;
10075 }
10076
10077 2424 void HeroClass::solid_push(solid_object* obj)
10078 {
10079
1/2
✓ Branch 0 taken 2424 times.
✗ Branch 1 not taken.
2424 if(obj == this) return; //can't push self
10080
10081 2424 zfix dx, dy;
10082 2424 int32_t hdir = -1;
10083 2424 solid_push_int(obj,dx,dy,hdir);
10084
10085
2/4
✓ Branch 0 taken 2424 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2424 times.
✗ Branch 3 not taken.
2424 if(!dx && !dy) return;
10086
10087 obj->doContactDamage(hdir);
10088
10089 bool t = obj->getTempNonsolid();
10090 obj->setTempNonsolid(true);
10091
10092 push_move(dx,dy);
10093
10094 obj->setTempNonsolid(t);
10095 2424 }
10096
10097 // A routine used exclusively by startwpn,
10098 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10099 733 void HeroClass::deselectbombs(int32_t super)
10100 {
10101
6/10
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 721 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 721 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 721 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 721 times.
733 if ( get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10102
2/6
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
721 if(getItemFamily(itemsbuf,Bwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10103 {
10104
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
721 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10105 721 Bwpn = Bweapon(temp);
10106 721 directItemB = directItem;
10107 721 game->bwpn = temp;
10108 721 }
10109
10110 else if (getItemFamily(itemsbuf,Xwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10111 {
10112 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10113 Xwpn = Bweapon(temp);
10114 directItemX = directItem;
10115 game->xwpn = temp;
10116 }
10117 else if (getItemFamily(itemsbuf,Ywpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10118 {
10119 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
10120 Ywpn = Bweapon(temp);
10121 directItemY = directItem;
10122 game->ywpn = temp;
10123 }
10124 else
10125 {
10126 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10127 Awpn = Bweapon(temp);
10128 directItemA = directItem;
10129 game->awpn = temp;
10130 }
10131 733 }
10132
10133 int32_t potion_life=0;
10134 int32_t potion_magic=0;
10135
10136 6181275 bool HeroClass::onWater(bool drownonly)
10137 {
10138 6181275 int32_t water = 0;
10139 6181275 int32_t types[4] = {0};
10140 6181275 int32_t x1 = x+4, x2 = x+11,
10141 6181275 y1 = y+9, y2 = y+15;
10142
2/2
✓ Branch 0 taken 228856 times.
✓ Branch 1 taken 5952419 times.
6181275 if (get_bit(quest_rules, qr_SMARTER_WATER))
10143 {
10144
4/4
✓ Branch 0 taken 1595 times.
✓ Branch 1 taken 227261 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1314 times.
230173 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10145
2/2
✓ Branch 0 taken 1439 times.
✓ Branch 1 taken 156 times.
1595 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10146
2/2
✓ Branch 0 taken 1317 times.
✓ Branch 1 taken 122 times.
1439 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10147 1317 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10148 228856 }
10149 else
10150 {
10151 5952419 types[0] = COMBOTYPE(x1,y1);
10152
10153
2/2
✓ Branch 0 taken 14829 times.
✓ Branch 1 taken 5937590 times.
5952419 if(MAPFFCOMBO(x1,y1))
10154 14829 types[0] = FFCOMBOTYPE(x1,y1);
10155
10156 5952419 types[1] = COMBOTYPE(x1,y2);
10157
10158
2/2
✓ Branch 0 taken 13914 times.
✓ Branch 1 taken 5938505 times.
5952419 if(MAPFFCOMBO(x1,y2))
10159 13914 types[1] = FFCOMBOTYPE(x1,y2);
10160
10161 5952419 types[2] = COMBOTYPE(x2,y1);
10162
10163
2/2
✓ Branch 0 taken 15061 times.
✓ Branch 1 taken 5937358 times.
5952419 if(MAPFFCOMBO(x2,y1))
10164 15061 types[2] = FFCOMBOTYPE(x2,y1);
10165
10166 5952419 types[3] = COMBOTYPE(x2,y2);
10167
10168
2/2
✓ Branch 0 taken 14121 times.
✓ Branch 1 taken 5938298 times.
5952419 if(MAPFFCOMBO(x2,y2))
10169 14121 types[3] = FFCOMBOTYPE(x2,y2);
10170
10171 5952419 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10172
2/2
✓ Branch 0 taken 14660 times.
✓ Branch 1 taken 5937759 times.
5952419 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10173 14660 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10174
10175
5/6
✓ Branch 0 taken 129959 times.
✓ Branch 1 taken 5822460 times.
✓ Branch 2 taken 122938 times.
✓ Branch 3 taken 7021 times.
✓ Branch 4 taken 116653 times.
✗ Branch 5 not taken.
6069072 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10176
4/4
✓ Branch 0 taken 116788 times.
✓ Branch 1 taken 6150 times.
✓ Branch 2 taken 116653 times.
✓ Branch 3 taken 135 times.
122938 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10177 116653 water = typec;
10178 }
10179
2/2
✓ Branch 0 taken 6063308 times.
✓ Branch 1 taken 117967 times.
6181275 if(water > 0)
10180 {
10181
1/2
✓ Branch 0 taken 117967 times.
✗ Branch 1 not taken.
117967 if(!drownonly) return true;
10182
4/8
✓ Branch 0 taken 67284 times.
✓ Branch 1 taken 50683 times.
✓ Branch 2 taken 67284 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 67284 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
117967 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10183 {
10184 50683 return true;
10185 }
10186 67284 }
10187 6130592 return false;
10188 6181275 }
10189
10190 bool HeroClass::mirrorBonk()
10191 {
10192 zfix tx = x, ty = y, tz = z;
10193 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10194 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10195 execute(info);
10196 bool fail = info.isUnwalkable();
10197
10198 if(!fail) //not solid, but check for water/pits...
10199 {
10200 if(onWater(true))
10201 fail = true;
10202 if(pitslide() || fallclk)
10203 fail = true;
10204 fallclk = 0;
10205 }
10206 x = tx; y = ty; z = tz;
10207 return fail;
10208 }
10209
10210 void HeroClass::doMirror(int32_t mirrorid)
10211 {
10212 if(z > 0 || fakez > 0) return; //No mirror in air
10213 if(mirrorid < 0)
10214 mirrorid = current_item_id(itype_mirror);
10215 if(mirrorid < 0) return;
10216
10217 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10218 {
10219 item_error();
10220 return;
10221 }
10222 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10223 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10224 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10225 for(auto pos : posarr)
10226 {
10227 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10228 {
10229 item_error();
10230 return;
10231 }
10232 }
10233
10234 itemdata const& mirror = itemsbuf[mirrorid];
10235 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10236 {
10237 paymagiccost(mirrorid);
10238 if(mirror.usesound2) sfx(mirror.usesound2);
10239
10240 doWarpEffect(mirror.misc2, true);
10241 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10242 {
10243 Quit = qCONT;
10244 skipcont = 1;
10245 }
10246 else //Act as Divine Escape
10247 {
10248 int32_t div_prot_temp=div_prot_item;
10249 restart_level();
10250 div_prot_item=div_prot_temp;
10251 magicitem=-1;
10252 magiccastclk=0;
10253 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10254 }
10255 }
10256 else
10257 {
10258 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10259 int32_t offscr = currscr - DMaps[currdmap].xoff;
10260 if(destdmap < 0)
10261 return;
10262 int32_t destscr = DMaps[destdmap].xoff + offscr;
10263 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10264 return;
10265 paymagiccost(mirrorid);
10266
10267 //Store some values to restore if 'warp fails'
10268 int32_t tLastEntrance = lastentrance,
10269 tLastEntranceDMap = lastentrance_dmap,
10270 tContScr = game->get_continue_scrn(),
10271 tContDMap = game->get_continue_dmap(),
10272 tPortalDMap = game->saved_mirror_portal.srcdmap;
10273 int32_t sourcescr = currscr, sourcedmap = currdmap;
10274 zfix tx = x, ty = y, tz = z;
10275 game->saved_mirror_portal.srcdmap = -1;
10276 action = none; FFCore.setHeroAction(none);
10277
10278 //Warp to new dmap
10279 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10280 mirror.usesound, 0, -1);
10281
10282 //Check for valid landing location
10283 if(mirrorBonk()) //Invalid landing, warp back!
10284 {
10285 action = none; FFCore.setHeroAction(none);
10286 lastentrance = tLastEntrance;
10287 lastentrance_dmap = tLastEntranceDMap;
10288 game->set_continue_scrn(tContScr);
10289 game->set_continue_dmap(tContDMap);
10290 x = tx;
10291 y = ty;
10292 z = tz;
10293 game->saved_mirror_portal.srcdmap = tPortalDMap;
10294 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10295 mirror.usesound, 0, -1);
10296 }
10297 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10298 {
10299 //Place the portal
10300 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10301 //Since it was placed after loading this screen, load the portal object now
10302 game->load_portal();
10303 //Don't immediately trigger the warp back
10304 mirror_portal.prox_active = false;
10305
10306 //Set continue point
10307 if(currdmap != game->get_continue_dmap())
10308 {
10309 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10310 }
10311 game->set_continue_dmap(currdmap);
10312 lastentrance_dmap = currdmap;
10313 lastentrance = game->get_continue_scrn();
10314 }
10315 }
10316 }
10317
10318 6406154 void HeroClass::handle_passive_buttons()
10319 {
10320 6406154 do_liftglove(-1,true);
10321 6406154 do_jump(-1,true);
10322 6406154 }
10323
10324 static bool did_passive_jump = false;
10325 6406180 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10326 {
10327
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 6406154 times.
6406180 if(passive) did_passive_jump = false;
10328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 else if(did_passive_jump) return false; //don't jump twice in the same frame
10329
10330
2/2
✓ Branch 0 taken 224905 times.
✓ Branch 1 taken 6181275 times.
6406180 if(nomove_action(action)) return false; //can't jump while ex. drowning
10331
2/2
✓ Branch 0 taken 50683 times.
✓ Branch 1 taken 6130592 times.
6181275 if(onWater(true)) return false; //Don't allow jumping off of water frame-perfectly...
10332
10333
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 6130566 times.
6130592 if(jumpid < 0)
10334 6130566 jumpid = current_item_id(itype_rocs,true,true);
10335
10336
2/2
✓ Branch 0 taken 5952414 times.
✓ Branch 1 taken 178178 times.
6130592 if(unsigned(jumpid) >= MAXITEMS) return false;
10337
4/4
✓ Branch 0 taken 178067 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 1411 times.
✓ Branch 3 taken 176656 times.
178178 if(inlikelike || charging) return false;
10338
1/2
✓ Branch 0 taken 176656 times.
✗ Branch 1 not taken.
176656 if(!checkitem_jinx(jumpid)) return false;
10339
10340 176656 itemdata const& itm = itemsbuf[jumpid];
10341
10342 176656 bool standing = isStanding(true);
10343
3/4
✓ Branch 0 taken 175691 times.
✓ Branch 1 taken 965 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 965 times.
176656 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10344
4/6
✓ Branch 0 taken 176656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 175691 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 965 times.
176656 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10345
3/4
✓ Branch 0 taken 173889 times.
✓ Branch 1 taken 1802 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173889 times.
175691 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10346 {
10347 1802 item_error();
10348 1802 return false;
10349 }
10350
10351 173889 byte intbtn = byte(itm.misc2&0xFF);
10352
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 173866 times.
173889 if(passive)
10353 {
10354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173866 times.
173866 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10355 173866 return false; //not pressed
10356 }
10357
10358 23 paymagiccost(jumpid);
10359
10360
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!standing)
10361 {
10362 ++extra_jump_count;
10363 fall = 0;
10364 fakefall = 0;
10365 if(hoverclk > 0)
10366 hoverclk = -hoverclk;
10367 }
10368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(itm.flags & ITEM_FLAG1)
10369 setFall(fall - itm.power);
10370 23 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10371 23 coyotetime = 65535; //jumped, so no coyotetime
10372 23 setOnSideviewLadder(false);
10373
10374 // Reset the ladder, unless on an unwalkable combo
10375
3/10
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
23 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
10376 reset_ladder();
10377
10378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(itm.usesound)
10379 23 sfx(itm.usesound,pan(x.getInt()));
10380
10381
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(passive)
10382 {
10383 did_passive_jump = true;
10384 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10385 }
10386 23 return true;
10387 6406180 }
10388 1082 void HeroClass::drop_liftwpn()
10389 {
10390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1082 times.
1082 if(!lift_wpn) return;
10391
10392 handle_lift(false); //sets position properly, accounting for large weapons
10393 auto liftid = current_item_id(itype_liftglove,true,true);
10394 itemdata const& glove = itemsbuf[liftid];
10395 auto lheight = liftheight+z+fakez;
10396 if(glove.flags & ITEM_FLAG1)
10397 {
10398 lift_wpn->z = 0;
10399 lift_wpn->fakez = lheight;
10400 }
10401 else lift_wpn->z = lheight;
10402 lift_wpn->dir = dir;
10403 lift_wpn->step = 0;
10404 lift_wpn->fakefall = 0;
10405 lift_wpn->fall = 0;
10406 if(glove.flags & ITEM_FLAG1)
10407 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10408 else
10409 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10410 Lwpns.add(lift_wpn);
10411 lift_wpn = nullptr;
10412 1082 }
10413 6406154 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10414 {
10415
1/2
✓ Branch 0 taken 6406154 times.
✗ Branch 1 not taken.
6406154 if(liftid < 0)
10416 6406154 liftid = current_item_id(itype_liftglove,true,true);
10417
2/2
✓ Branch 0 taken 11290 times.
✓ Branch 1 taken 6394864 times.
6406154 if(!can_lift(liftid)) return;
10418 11290 itemdata const& glove = itemsbuf[liftid];
10419 11290 byte intbtn = byte(glove.misc1&0xFF);
10420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11290 times.
11290 if(passive)
10421 {
10422
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 11218 times.
11290 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10423 11218 return; //not pressed
10424 72 }
10425
10426 72 bool had_weapon = lift_wpn;
10427
10428
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
125 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10429
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 2 times.
55 (checkbunny(liftid) && checkmagiccost(liftid))))
10430 {
10431 2 item_error();
10432 2 return;
10433 }
10434
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
70 if(glove.script!=0 && (FFCore.doscript(ScriptType::Item, liftid) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10435 return;
10436
10437 70 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10438
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if(glove.script)
10439 {
10440 if(!paidmagic)
10441 {
10442 paidmagic = true;
10443 paymagiccost(liftid);
10444 }
10445
10446 int i = liftid;
10447 FFCore.reset_script_engine_data(ScriptType::Item, i);
10448 ZScriptVersion::RunScript(ScriptType::Item, glove.script, i);
10449 FFCore.deallocateAllArrays(ScriptType::Item,i);
10450
10451 bool has_weapon = lift_wpn;
10452 if(has_weapon != had_weapon) //Item action script changed the lift information
10453 {
10454 if(passive)
10455 {
10456 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10457 }
10458 return;
10459 }
10460 }
10461
10462
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 53 times.
70 if(lift_wpn)
10463 {
10464
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!paidmagic)
10465 {
10466 paidmagic = true;
10467 paymagiccost(liftid);
10468 }
10469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!liftclk)
10470 {
10471 //Throw the weapon!
10472 //hero's direction and position
10473 17 handle_lift(false); //sets position properly, accounting for large weapons
10474 17 auto lheight = liftheight+z+fakez;
10475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(glove.flags & ITEM_FLAG1)
10476 {
10477 lift_wpn->z = 0;
10478 lift_wpn->fakez = lheight;
10479 }
10480 17 else lift_wpn->z = lheight;
10481 17 lift_wpn->dir = dir;
10482 //Configured throw speed in both axes
10483 17 lift_wpn->step = zfix(glove.misc2)/100;
10484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(glove.flags & ITEM_FLAG1)
10485 {
10486 lift_wpn->fakefall = -glove.misc3;
10487 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10488 }
10489 else
10490 {
10491 17 lift_wpn->fall = -glove.misc3;
10492 17 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10493 }
10494 17 Lwpns.add(lift_wpn);
10495 17 lift_wpn = nullptr;
10496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(glove.usesound2)
10497 17 sfx(glove.usesound2,pan(int32_t(x)));
10498 17 }
10499
10500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(passive)
10501 {
10502 17 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10503 17 }
10504 17 return;
10505 }
10506
10507 53 bool lifted = false;
10508 //Check for a liftable weapon
10509 //if(!lifted)
10510 {
10511 53 zfix hx, hy, hw, hh;
10512
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 17 times.
53 switch(dir)
10513 {
10514 case up:
10515 18 hx = x;
10516 18 hy = y-8;
10517 18 hw = 16;
10518 18 hh = bigHitbox ? 8 : 16;
10519 18 break;
10520 case down:
10521 9 hx = x;
10522 9 hy = y+16;
10523 9 hw = 16;
10524 9 hh = 8;
10525 9 break;
10526 case left:
10527 9 hx = x-8;
10528 9 hy = y;
10529 9 hw = 8;
10530 9 hh = 16;
10531 9 break;
10532 case right:
10533 17 hx = x+16;
10534 17 hy = y;
10535 17 hw = 8;
10536 17 hh = 16;
10537 17 break;
10538 }
10539
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 20 times.
73 for(int32_t q = 0; q < Lwpns.Count(); ++q)
10540 {
10541 20 weapon* w = (weapon*)Lwpns.spr(q);
10542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 if((w->lift_level && w->lift_level <= glove.fam_type))
10543 {
10544 if(!w->hit(hx,hy,0,hw,hh,1))
10545 continue;
10546 lift(w, w->lift_time, w->lift_height);
10547 Lwpns.remove(w);
10548 lifted = true;
10549 break;
10550 }
10551 20 }
10552 }
10553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(!lifted) //Check for a liftable combo
10554 {
10555 53 zfix bx, by;
10556 53 zfix bx2, by2;
10557
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 17 times.
53 switch(dir)
10558 {
10559 case up:
10560 18 by = y + (bigHitbox ? -2 : 6);
10561 18 by2 = by;
10562 18 bx = x + 4;
10563 18 bx2 = bx + 8;
10564 18 break;
10565 case down:
10566 9 by = y + 17;
10567 9 by2 = by;
10568 9 bx = x + 4;
10569 9 bx2 = bx + 8;
10570 9 break;
10571 case left:
10572 9 by = y + (bigHitbox ? 0 : 8);
10573 9 by2 = y + 8;
10574 9 bx = x - 2;
10575 9 bx2 = x - 2;
10576 9 break;
10577 case right:
10578 17 by = y + (bigHitbox ? 0 : 8);
10579 17 by2 = y + 8;
10580 17 bx = x + 17;
10581 17 bx2 = x + 17;
10582 17 break;
10583 }
10584 53 int32_t pos = COMBOPOS_B(bx,by);
10585 53 int32_t pos2 = COMBOPOS_B(bx2,by2);
10586 53 int32_t foundpos = -1;
10587
10588
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 367 times.
403 for(auto lyr = 6; lyr >= 0; --lyr)
10589 {
10590 367 mapscr* scr = FFCore.tempScreens[lyr];
10591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
367 if(pos > -1)
10592 {
10593 367 newcombo const& cmb = combobuf[scr->data[pos]];
10594
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 17 times.
367 if(cmb.liftflags & LF_LIFTABLE)
10595 {
10596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(do_lift_combo(lyr,pos,liftid))
10597 {
10598 17 lifted = true;
10599 17 break;
10600 }
10601 }
10602 350 }
10603
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 252 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
350 if(pos != pos2 && pos2 > -1)
10604 {
10605 98 newcombo const& cmb2 = combobuf[scr->data[pos2]];
10606
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(cmb2.liftflags & LF_LIFTABLE)
10607 {
10608 if(do_lift_combo(lyr,pos2,liftid))
10609 {
10610 lifted = true;
10611 break;
10612 }
10613 }
10614 98 }
10615 350 }
10616 53 }
10617
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 36 times.
53 if(!lifted) return;
10618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!paidmagic)
10619 {
10620 17 paidmagic = true;
10621 17 paymagiccost(liftid);
10622 17 }
10623 17 set_liftflags(liftid);
10624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(passive)
10625 17 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10626 17 return;
10627 6406154 }
10628 2375 void HeroClass::handle_lift(bool dec)
10629 {
10630
1/2
✓ Branch 0 taken 2375 times.
✗ Branch 1 not taken.
2375 if(lift_wpn)
10631 2375 lift_wpn->fakez = 0;
10632 else liftclk = 0;
10633
2/2
✓ Branch 0 taken 1977 times.
✓ Branch 1 taken 398 times.
2375 if(liftclk <= (dec?1:0))
10634 {
10635 1977 liftclk = 0;
10636 1977 tliftclk = 0;
10637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1977 times.
1977 if(lift_wpn)
10638 {
10639
2/4
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1977 times.
1977 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
10640 {
10641 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
10642 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
10643 }
10644 else
10645 {
10646 1977 lift_wpn->x = x;
10647 1977 lift_wpn->y = y;
10648 }
10649 1977 lift_wpn->z = liftheight;
10650 1977 }
10651
2/2
✓ Branch 0 taken 1960 times.
✓ Branch 1 taken 17 times.
1977 if(action == lifting)
10652 {
10653 17 action = none; FFCore.setHeroAction(none);
10654 17 }
10655 1977 return;
10656 }
10657
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 199 times.
398 if(dec) --liftclk;
10658 double xdist, ydist;
10659 398 double perc = (liftclk/double(tliftclk));
10660
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 120 times.
✓ Branch 4 taken 130 times.
398 switch(dir)
10661 {
10662 case up:
10663 {
10664 44 xdist = 0;
10665 44 ydist = -16;
10666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(lift_wpn->txsz > 1)
10667 {
10668 xdist = -((lift_wpn->txsz*8)-8);
10669 }
10670 44 else xdist = 0;
10671
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(lift_wpn->tysz > 1)
10672 {
10673 ydist = -(lift_wpn->tysz*16);
10674 }
10675 44 ydist *= perc;
10676 44 break;
10677 }
10678 case down:
10679 {
10680 104 xdist = 0;
10681 104 ydist = 16;
10682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(lift_wpn->txsz > 1)
10683 {
10684 xdist = -((lift_wpn->txsz*8)-8);
10685 }
10686 104 else xdist = 0;
10687 104 ydist *= perc;
10688 104 break;
10689 }
10690 case left:
10691 {
10692 120 xdist = -16;
10693 120 ydist = 0;
10694
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(lift_wpn->txsz > 1)
10695 {
10696 xdist = -(lift_wpn->txsz*16);
10697 }
10698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(lift_wpn->tysz > 1)
10699 {
10700 ydist = -((lift_wpn->tysz*8)-8);
10701 }
10702 120 else ydist = 0;
10703 120 xdist *= perc;
10704 120 break;
10705 }
10706 case right:
10707 {
10708 130 xdist = 16;
10709 130 ydist = 0;
10710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(lift_wpn->tysz > 1)
10711 {
10712 ydist = -((lift_wpn->tysz*8)-8);
10713 }
10714 130 else ydist = 0;
10715 130 xdist *= perc;
10716 130 break;
10717 }
10718 }
10719
10720 398 lift_wpn->x = x + xdist;
10721 398 lift_wpn->y = y + ydist;
10722 398 lift_wpn->z = liftheight*(1.0-perc);
10723 2375 }
10724 6406171 bool HeroClass::can_lift(int32_t gloveid)
10725 {
10726
2/2
✓ Branch 0 taken 6393532 times.
✓ Branch 1 taken 12639 times.
6406171 if(unsigned(gloveid) >= MAXITEMS) return false;
10727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12639 times.
12639 if(lstunclock) return false;
10728
1/2
✓ Branch 0 taken 12639 times.
✗ Branch 1 not taken.
12639 if(!checkitem_jinx(gloveid)) return false;
10729 12639 itemdata const& glove = itemsbuf[gloveid];
10730
2/3
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 11307 times.
✗ Branch 2 not taken.
12639 switch(action)
10731 {
10732 case none: case walking:
10733 11307 break;
10734
10735 case swimming:
10736 if(glove.flags & ITEM_FLAG2)
10737 break;
10738 return false;
10739
10740 default:
10741 1332 return false;
10742 }
10743 11307 return true;
10744 6406171 }
10745 17 void HeroClass::lift(weapon* w, byte timer, zfix height)
10746 {
10747 17 lift_wpn = w;
10748 17 liftclk = timer;
10749 17 tliftclk = timer;
10750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(height < 0)
10751 liftheight = 0;
10752 17 else liftheight = height;
10753 17 }
10754
10755 1 void HeroClass::doSwitchHook(byte style)
10756 {
10757 1 hs_switcher = true;
10758 1 pull_hero = true;
10759 //{ Load hook weapons, set them to obey special drawing
10760 1 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
10761 1 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
10762
10763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w)
10764 1 w->switch_hooked = true;
10765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hw)
10766 1 hw->switch_hooked = true;
10767
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
10768 {
10769 5 chainlinks.spr(j)->switch_hooked = true;
10770 5 }
10771 //}
10772
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hooked_combopos > -1)
10773 {
10774 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
10775 hooked_layerbits = 0;
10776 for(auto q = 0; q < 7; ++q)
10777 hooked_undercombos[q] = -1;
10778 uint16_t plpos = COMBOPOS(x+8,y+8);
10779 for(auto q = max_layer; q > -1; --q)
10780 {
10781 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
10782 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
10783 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
10784 fl2 = FFCore.tempScreens[q]->sflag[plpos];
10785 bool isPush = false;
10786 if(isSwitchHookable(cmb))
10787 {
10788 if(cmb.type == cSWITCHHOOK)
10789 {
10790 uint16_t plpos = COMBOPOS(x+8,y+8);
10791 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
10792 continue; //don't swap with non-zero combo
10793 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
10794 continue; //too low a switchhook level
10795 hooked_layerbits |= 1<<q; //Swapping
10796 if(cmb.usrflags&cflag3)
10797 {
10798 if(cmb.usrflags&cflag6)
10799 {
10800 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10801 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10802 }
10803 else
10804 {
10805 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10806 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10807 }
10808 }
10809 else
10810 {
10811 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10812 if(cmb.usrflags&cflag7) //counts as 'pushblock'
10813 isPush = true;
10814 }
10815 }
10816 else if(isCuttableType(cmb.type))
10817 {
10818 if(isCuttableNextType(cmb.type))
10819 {
10820 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10821 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10822 }
10823 else
10824 {
10825 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10826 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10827 }
10828 hooked_layerbits |= 1<<q; //Swapping
10829 }
10830 else
10831 {
10832 hooked_layerbits |= 1<<q; //Swapping
10833 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10834 }
10835 }
10836 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
10837 {
10838 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
10839 && hasMainGuy())
10840 {
10841 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
10842 continue;
10843 }
10844 if(fl1 == mfPUSHED)
10845 {
10846 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
10847 continue;
10848 }
10849 if(!isPush) switch(fl1)
10850 {
10851 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10852 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10853 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10854 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10855 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10856 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10857 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10858 isPush = true;
10859 }
10860 if(!isPush) switch(cmb.flag)
10861 {
10862 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10863 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10864 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10865 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10866 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10867 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10868 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10869 isPush = true;
10870 }
10871 if(isPush) //Check for block holes / triggers
10872 {
10873 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
10874 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
10875 {
10876 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10877 }
10878 else if(!get_bit(quest_rules, qr_BLOCKHOLE_SAME_ONLY))
10879 {
10880 auto maxLayer = get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
10881 for(auto lyr = 0; lyr < maxLayer; ++lyr)
10882 {
10883 if(lyr == q) continue;
10884 switch(FFCore.tempScreens[q]->sflag[plpos])
10885 {
10886 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10887 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10888 lyr=7;
10889 break;
10890 }
10891 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
10892 {
10893 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10894 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10895 lyr=7;
10896 break;
10897 }
10898 }
10899 }
10900 }
10901 }
10902 }
10903 }
10904 1 switch_hooked = true;
10905 1 switchhookstyle = style;
10906
1/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 switch(style)
10907 {
10908 default: case swPOOF:
10909 {
10910 1 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
10911
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
10912
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(x, y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1)
10914 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object)
10916
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(switching_object->x, switching_object->y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10917 1 break;
10918 }
10919 case swFLICKER:
10920 {
10921 switchhookmaxtime = switchhookclk = 64;
10922 break;
10923 }
10924 case swRISE:
10925 {
10926 switchhookmaxtime = switchhookclk = 64;
10927 break;
10928 }
10929 }
10930 1 }
10931
10932 28373 bool HeroClass::startwpn(int32_t itemid)
10933 {
10934
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 28108 times.
28373 if(itemid < 0) return false;
10935 28108 itemdata const& itm = itemsbuf[itemid];
10936
5/6
✓ Branch 0 taken 6831 times.
✓ Branch 1 taken 21277 times.
✓ Branch 2 taken 5374 times.
✓ Branch 3 taken 15903 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
28159 if(((dir==up && y<24) || (dir==down && y>128) ||
10937
6/6
✓ Branch 0 taken 7783 times.
✓ Branch 1 taken 8120 times.
✓ Branch 2 taken 8116 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 28053 times.
28108 (dir==left && x<32) || (dir==right && x>208)) && !(get_bit(quest_rules,qr_ITEMSONEDGES) || inlikelike))
10938 51 return false;
10939
10940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28057 times.
28057 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
10941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28057 times.
28057 if(liftonly)
10942 {
10943 dowpn = -1;
10944 switch(itm.family)
10945 {
10946 case itype_bomb:
10947 case itype_sbomb:
10948 if(itm.flags & ITEM_FLAG4)
10949 do_liftglove(-1,false);
10950 break;
10951 case itype_liftglove:
10952 do_liftglove(-1,false);
10953 break;
10954 }
10955 return false;
10956 }
10957
10958 28057 int32_t wx=x;
10959 28057 int32_t wy=y-fakez;
10960 28057 int32_t wz=z;
10961 28057 bool ret = true;
10962
10963
5/5
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6818 times.
✓ Branch 2 taken 5362 times.
✓ Branch 3 taken 7765 times.
✓ Branch 4 taken 8108 times.
28057 switch(dir)
10964 {
10965 case up:
10966 6818 wy-=16;
10967 6818 break;
10968
10969 case down:
10970 5362 wy+=16;
10971 5362 break;
10972
10973 case left:
10974 7765 wx-=16;
10975 7765 break;
10976
10977 case right:
10978 8108 wx+=16;
10979 8108 break;
10980 }
10981
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28057 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
10982
10983
15/27
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
✓ Branch 2 taken 1163 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 26 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 185 times.
✓ Branch 11 taken 718 times.
✓ Branch 12 taken 15 times.
✓ Branch 13 taken 1535 times.
✓ Branch 14 taken 13287 times.
✓ Branch 15 taken 1077 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 823 times.
✓ Branch 18 taken 10 times.
✓ Branch 19 taken 8962 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
28057 switch(itm.family)
10984 {
10985 case itype_liftglove:
10986 {
10987 do_liftglove(itemid,false);
10988 dowpn = -1;
10989 ret = false;
10990 break;
10991 }
10992 case itype_potion:
10993 {
10994
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10995 {
10996 return item_error();
10997 }
10998
10999 23 paymagiccost(itemid);
11000
11001
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23 if(itm.misc1 || itm.misc2)
11002 {
11003 23 refill_what=REFILL_ALL;
11004 23 refill_why=itemid;
11005 23 StartRefill(REFILL_ALL);
11006 23 potion_life = game->get_life();
11007 23 potion_magic = game->get_magic();
11008
11009 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11010 //music_pause();
11011 23 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11012
2/2
✓ Branch 0 taken 4932 times.
✓ Branch 1 taken 23 times.
4955 while(refill())
11013 {
11014 4932 do_refill_waitframe();
11015 }
11016
11017 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11018 //music_resume();
11019 23 ret = false;
11020 23 }
11021
11022 23 break;
11023 }
11024 case itype_bottle:
11025 {
11026 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11027 {
11028 return item_error();
11029 }
11030 if(itm.script!=0 && (FFCore.doscript(ScriptType::Item, itemid) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
11031 return false;
11032
11033 size_t bind = game->get_bottle_slot(itm.misc1);
11034 bool paidmagic = false;
11035 if(itm.script)
11036 {
11037 paidmagic = true;
11038 paymagiccost(itemid);
11039
11040 int i = itemid;
11041 FFCore.reset_script_engine_data(ScriptType::Item, i);
11042 ZScriptVersion::RunScript(ScriptType::Item, itm.script, i);
11043 bind = game->get_bottle_slot(itm.misc1);
11044 }
11045 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
11046 if(bt)
11047 {
11048 word toFill[3] = { 0 };
11049 for(size_t q = 0; q < 3; ++q)
11050 {
11051 char c = bt->counter[q];
11052 if(c > -1)
11053 {
11054 if(bt->flags & (1<<q))
11055 {
11056 toFill[q] = (bt->amount[q]==100)
11057 ? game->get_maxcounter(c)
11058 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
11059 }
11060 else toFill[q] = bt->amount[q];
11061 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
11062 {
11063 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
11064 }
11065 }
11066 }
11067 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
11068 bool run = max > 0;
11069 if(get_bit(quest_rules, qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
11070 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
11071 else
11072 {
11073 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
11074 run = true;
11075 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
11076 run = true;
11077 }
11078 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
11079 {
11080 if(bt->flags & BTFLAG_CURESWJINX)
11081 {
11082 swordclk = 0;
11083 verifyAWpn();
11084 }
11085 if(bt->flags & BTFLAG_CUREITJINX)
11086 itemclk = 0;
11087 if(!paidmagic)
11088 paymagiccost(itemid);
11089 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11090 sfx(itm.usesound,pan(x.getInt()));
11091 for(size_t q = 0; q < 20; ++q)
11092 do_refill_waitframe();
11093 double inc = max/60.0; //1 second
11094 double xtra[3]{ 0 };
11095 for(size_t q = 0; q < 60; ++q)
11096 {
11097 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
11098 sfx(QMisc.miscsfx[sfxREFILL]);
11099 for(size_t j = 0; j < 3; ++j)
11100 {
11101 xtra[j] += inc;
11102 word f = floor(xtra[j]);
11103 xtra[j] -= f;
11104 if(toFill[j] > f)
11105 {
11106 toFill[j] -= f;
11107 game->change_counter(f,bt->counter[j]);
11108 }
11109 else if(toFill[j])
11110 {
11111 game->change_counter(toFill[j],bt->counter[j]);
11112 toFill[j] = 0;
11113 }
11114 }
11115 do_refill_waitframe();
11116 }
11117 for(size_t j = 0; j < 3; ++j)
11118 {
11119 if(toFill[j])
11120 {
11121 game->change_counter(toFill[j],bt->counter[j]);
11122 toFill[j] = 0;
11123 }
11124 }
11125 for(size_t q = 0; q < 20; ++q)
11126 do_refill_waitframe();
11127 game->set_bottle_slot(itm.misc1, bt->next_type);
11128 }
11129 }
11130
11131 dowpn = -1;
11132 ret = false;
11133 break;
11134 }
11135
11136 case itype_note:
11137 {
11138 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11139 {
11140 return item_error();
11141 }
11142 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
11143 {
11144 sfx(itm.usesound);
11145 donewmsg(itm.misc1);
11146 paymagiccost(itemid);
11147 }
11148 dowpn = -1;
11149 ret = false;
11150 break;
11151 }
11152
11153 case itype_mirror:
11154 doMirror(itemid);
11155 if(Quit)
11156 return false;
11157 ret = false;
11158 break;
11159
11160 case itype_rocs:
11161 {
11162
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 3 times.
26 if(!do_jump(itemid,false)) return false;
11163 23 ret = false;
11164 }
11165 23 break;
11166
11167 case itype_letter:
11168 {
11169
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 if(current_item(itype_letter)==i_letter &&
11170
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11171
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].guy &&
11172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11173
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11174 4 checkbunny(itemid)
11175 )
11176 {
11177 4 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11178
11179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(usedid != -1)
11180 4 getitem(usedid, true, true);
11181
11182 4 sfx(tmpscr[currscr<128?0:1].secretsfx);
11183 4 setupscreen();
11184 4 action=none; FFCore.setHeroAction(none);
11185 4 }
11186
11187 4 ret = false;
11188 }
11189 4 break;
11190
11191 case itype_whistle:
11192 {
11193 bool whistleflag;
11194
11195
4/4
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 177 times.
185 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11196 {
11197 8 return item_error();
11198 }
11199
11200 177 paymagiccost(itemid);
11201 177 sfx(itm.usesound);
11202
11203
4/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 78 times.
177 if(dir==up || dir==right)
11204 99 ++blowcnt;
11205 else
11206 78 --blowcnt;
11207
11208 177 int sfx_count = 0;
11209
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32757 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32761 times.
✓ Branch 6 taken 32580 times.
✓ Branch 7 taken 185 times.
32757 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < 180))
11210 {
11211 32580 sfx_count += 1;
11212 32580 advanceframe(true);
11213
11214
1/2
✓ Branch 0 taken 32580 times.
✗ Branch 1 not taken.
32580 if(Quit)
11215 return false;
11216 }
11217
11218
9/14
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 181 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 181 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 181 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 181 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 185 times.
✓ Branch 13 taken 4 times.
185 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11219
11220
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 17 times.
185 if((whistleflag=findentrance(x,y,mfWHISTLE,get_bit(quest_rules, qr_PERMANENT_WHISTLE_SECRETS))))
11221 17 didstuff |= did_whistle;
11222
11223
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 166 times.
185 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
11224 19 return false;
11225
11226
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 162 times.
166 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
11227
11228
4/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 136 times.
166 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11229
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 || (tmpscr->flags7&fWHISTLEPAL))
11230 {
11231 30 whistleclk=0; // signal to start drying lake or doing other stuff
11232 30 }
11233 else
11234 {
11235 136 int32_t where = itm.misc1;
11236
11237
1/2
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
136 if(where>right) where=dir^1;
11238
11239
5/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 43 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 89 times.
225 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
11240
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
93 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11241
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 89 times.
✗ Branch 11 not taken.
178 Lwpns.add(new weapon((zfix)(where==left?zfix(240):where==right?zfix(0):x),
11242
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 89 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 89 times.
✗ Branch 9 not taken.
89 (zfix)(where==down?zfix(0):where==up?zfix(160):y),
11243
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 (zfix)0,
11244 wWind,
11245 0, //type
11246 0,
11247 89 where,
11248
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11249
11250 132 whistleitem=itemid;
11251 }
11252
11253 162 ret = false;
11254 }
11255 162 break;
11256
11257 case itype_bomb:
11258 {
11259 //Remote detonation
11260
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 713 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 717 times.
718 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
11261 {
11262 1 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11263
11264
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
11265 {
11266 //If this ever needs a version check, in the future. -z
11267 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
11268 {
11269 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11270 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11271 }
11272 ew->misc=50;
11273 ew->clk=ew->misc-3;
11274 ew->id=wBomb;
11275 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11276 }
11277
11278 1 deselectbombs(false);
11279 1 return false;
11280 }
11281
11282
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
717 if((itm.flags & ITEM_FLAG4) && lift_wpn)
11283 {
11284 do_liftglove(-1,false); //Throw the already-held weapon
11285 return false;
11286 }
11287
2/4
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 717 times.
717 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11288 {
11289 return item_error();
11290 }
11291
11292 717 paymagiccost(itemid);
11293
11294
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(itm.misc1>0) // If not remote bombs
11295 717 deselectbombs(false);
11296
11297
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 578 times.
717 if(isdungeon())
11298 {
11299
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 63 times.
578 wy=zc_max(wy,16);
11300 578 }
11301
11302
4/8
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 717 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 717 times.
✗ Branch 7 not taken.
1434 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
11303
2/4
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 717 times.
✗ Branch 3 not taken.
717 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true);
11304 717 bool lifted = false;
11305
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(itm.flags & ITEM_FLAG4)
11306 {
11307 auto liftid = current_item_id(itype_liftglove);
11308 itemdata const& glove = itemsbuf[liftid];
11309 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
11310 {
11311 lift(wpn,itm.misc5,itm.misc6);
11312 set_liftflags(liftid);
11313 lifted = true;
11314 }
11315 }
11316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
717 if(!lifted)
11317 {
11318 717 Lwpns.add(wpn);
11319 717 sfx(WAV_PLACE,pan(wx));
11320 717 }
11321 }
11322 717 break;
11323
11324 case itype_sbomb:
11325 {
11326 //Remote detonation
11327
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
11328 {
11329 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11330
11331 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
11332 {
11333 ew->misc=50;
11334 ew->clk=ew->misc-3;
11335 ew->id=wSBomb;
11336 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11337 }
11338
11339 deselectbombs(true);
11340 return false;
11341 }
11342
11343
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 if((itm.flags & ITEM_FLAG4) && lift_wpn)
11344 {
11345 do_liftglove(-1,false); //Throw the already-held weapon
11346 return false;
11347 }
11348
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11349 {
11350 return item_error();
11351 }
11352
11353 15 paymagiccost(itemid);
11354
11355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itm.misc1>0) // If not remote bombs
11356 15 deselectbombs(true);
11357
11358
6/12
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
15 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true);
11359 15 bool lifted = false;
11360
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(itm.flags & ITEM_FLAG4)
11361 {
11362 auto liftid = current_item_id(itype_liftglove);
11363 itemdata const& glove = itemsbuf[liftid];
11364 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
11365 {
11366 lift(wpn,itm.misc5,itm.misc6);
11367 set_liftflags(liftid);
11368 lifted = true;
11369 }
11370 }
11371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(!lifted)
11372 {
11373 15 Lwpns.add(wpn);
11374 15 sfx(WAV_PLACE,pan(wx));
11375 15 }
11376 }
11377 15 break;
11378
11379 case itype_wand:
11380 {
11381
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 1096 times.
1535 if(Lwpns.idCount(wMagic))
11382 {
11383 439 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11384 439 return false;
11385 }
11386
11387 1096 int32_t bookid = current_item_id(itype_book);
11388
3/4
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 653 times.
1096 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11389
11390
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1096 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
11391 {
11392 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11393 return false;
11394 }
11395
11396
4/6
✓ Branch 0 taken 1096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1096 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1095 times.
✓ Branch 5 taken 1 times.
1096 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11397 {
11398 1 return item_error();
11399 }
11400
11401
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 3 times.
1095 if(Lwpns.idCount(wBeam))
11402 3 Lwpns.del(Lwpns.idFirst(wBeam));
11403
11404 int32_t type, pow;
11405
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 666 times.
1095 if ( get_bit(quest_rules,qr_BROKENBOOKCOST) )
11406 {
11407
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 79 times.
429 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11408
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 79 times.
429 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11409 429 }
11410 else
11411 {
11412
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
666 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11413
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
666 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11414 }
11415
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2190 times.
✓ Branch 4 taken 1095 times.
✓ Branch 5 taken 1095 times.
2190 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
2190 if(dir!=(i^1))
11417 {
11418
5/10
✓ Branch 0 taken 1095 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1095 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1095 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1095 times.
✗ Branch 9 not taken.
1095 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11419
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 653 times.
1095 if(paybook)
11420 653 magic->linkedItem = bookid;
11421 //magic->dir = this->dir; //Save player dir for special weapons.
11422 1095 Lwpns.add(magic);
11423 1095 }
11424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
1095 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11425 1095 paymagiccost(itemid);
11426 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11427
11428
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 653 times.
1095 if(paybook)
11429 653 paymagiccost(current_item_id(itype_book));
11430
11431
2/2
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 442 times.
1095 if(bookid != -1)
11432 {
11433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 653 times.
653 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
11434 {
11435 sfx(itemsbuf[bookid].misc2,pan(wx));
11436 }
11437 else
11438 {
11439 653 sfx(itm.usesound,pan(wx));
11440 }
11441 653 }
11442 else
11443 442 sfx(itm.usesound,pan(wx));
11444 }
11445 /*
11446 // Fireball Wand
11447 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
11448 switch (dir)
11449 {
11450 case up:
11451 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
11452 Lwpns.spr(Lwpns.Count()-1)->dir=up;
11453 break;
11454 case down:
11455 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
11456 Lwpns.spr(Lwpns.Count()-1)->dir=down;
11457 break;
11458 case left:
11459 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
11460 Lwpns.spr(Lwpns.Count()-1)->dir=left;
11461 break;
11462 case right:
11463 Lwpns.spr(Lwpns.Count()-1)->angle=0;
11464 Lwpns.spr(Lwpns.Count()-1)->dir=right;
11465 break;
11466 }
11467 Lwpns.spr(Lwpns.Count()-1)->clk=16;
11468 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
11469 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
11470 */
11471 1095 break;
11472
11473 case itype_sword:
11474 {
11475
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13287 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
11476 {
11477 return item_error();
11478 }
11479
11480
4/4
✓ Branch 0 taken 2607 times.
✓ Branch 1 taken 10680 times.
✓ Branch 2 taken 2607 times.
✓ Branch 3 taken 10680 times.
13287 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
11481 {
11482 2607 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11483 2607 return false;
11484 }
11485
11486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10680 times.
10680 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
11487 10680 paymagiccost(itemid);
11488 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11489 float temppower;
11490
11491
1/2
✓ Branch 0 taken 10680 times.
✗ Branch 1 not taken.
10680 if(itm.flags & ITEM_FLAG2)
11492 {
11493 10680 temppower=game->get_hero_dmgmult()*itm.power;
11494 10680 temppower=temppower*itm.misc2;
11495 10680 temppower=temppower/100;
11496 10680 }
11497 else
11498 {
11499 temppower = game->get_hero_dmgmult()*itm.misc2;
11500 }
11501
11502 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
11503 //Add weapon script to sword beams.
11504
5/10
✓ Branch 0 taken 10680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10680 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10680 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10680 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10680 times.
✗ Branch 9 not taken.
10680 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
11505 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
11506 //w->weaponscript = itm.weaponscript;
11507 //w->canrunscript = 0;
11508 10680 sfx(WAV_BEAM,pan(wx));
11509 }
11510 10680 break;
11511
11512 case itype_candle:
11513 {
11514 1077 int32_t countid = itemid;
11515
2/2
✓ Branch 0 taken 1049 times.
✓ Branch 1 taken 28 times.
1077 if(get_bit(quest_rules, qr_CANDLES_SHARED_LIMIT))
11516 1049 countid = -itype_candle;
11517
5/6
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 266 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 1067 times.
1077 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
11518 {
11519 10 return false;
11520 }
11521
11522
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1067 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 1004 times.
1067 if(Lwpns.idCount(wFire) >= (itm.misc2 < 1 ? 2 : itm.misc2))
11523 {
11524 63 return false;
11525 }
11526
11527
3/4
✓ Branch 0 taken 1004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 996 times.
1004 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11528 {
11529 8 return item_error();
11530 }
11531
11532 996 paymagiccost(itemid);
11533
11534
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 248 times.
996 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
11535
11536
4/8
✓ Branch 0 taken 996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 996 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 996 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 996 times.
✗ Branch 7 not taken.
1992 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
11537 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11538 996 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11539
2/4
✓ Branch 0 taken 996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 996 times.
✗ Branch 3 not taken.
996 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11540 996 sfx(itm.usesound,pan(wx));
11541 996 attack=wFire;
11542 }
11543 996 break;
11544
11545 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
11546 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
11547 {
11548 int32_t wtype = wScript1 + (itm.family-itype_script1);
11549 if(Lwpns.idCount(wtype))
11550 return false;
11551
11552 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11553 {
11554 return item_error();
11555 }
11556
11557 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11558 paymagiccost(itemid);
11559
11560 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11561 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11562 sfx(itm.usesound,pan(wx));
11563 }
11564 break;
11565
11566 case itype_icerod:
11567 {
11568 if(Lwpns.idCount(wIce))
11569 return false;
11570
11571 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11572 {
11573 return item_error();
11574 }
11575
11576 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11577 paymagiccost(itemid);
11578
11579 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11580 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11581 sfx(itm.usesound,pan(wx));
11582 }
11583 break;
11584
11585 case itype_arrow:
11586 {
11587
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 823 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 789 times.
823 if(Lwpns.idCount(wArrow) >= (itm.misc2 < 1 ? 1 : itm.misc2))
11588 34 return false;
11589
11590
2/4
✓ Branch 0 taken 789 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 789 times.
789 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11591 {
11592 return item_error();
11593 }
11594
11595 789 paymagiccost(itemid);
11596
11597
6/12
✓ Branch 0 taken 789 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 789 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 789 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 789 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 789 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 789 times.
✗ Branch 11 not taken.
789 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11598 789 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
11599 789 sfx(itm.usesound,pan(wx));
11600 }
11601 789 break;
11602
11603 case itype_bait:
11604 {
11605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
11606 return false;
11607
11608
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if(!checkbunny(itemid))
11609 3 return item_error();
11610
11611
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 bool grumble = (tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)));
11612
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 bool checkcost = grumble || !(itm.flags & ITEM_FLAG4);
11613
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 bool paycost = grumble || !(itm.flags & (ITEM_FLAG4|ITEM_FLAG5));
11614
11615
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 if(!grumble && (itm.flags & ITEM_FLAG2))
11616 return item_error(); //Only usable for grumble rooms
11617
11618
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 if(checkcost && !checkmagiccost(itemid))
11619 return item_error();
11620
11621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(paycost)
11622 7 paymagiccost(itemid);
11623 7 sfx(itm.usesound,pan(wx));
11624
11625
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(grumble)
11626 {
11627
4/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
7 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
11628 7 fadeclk=66;
11629 7 dismissmsg();
11630 7 clear_bitmap(pricesdisplaybuf);
11631 7 set_clip_state(pricesdisplaybuf, 1);
11632 // putscr(scrollbuf,0,0,tmpscr);
11633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
11634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(!(itm.flags & ITEM_FLAG3)) //"Don't remove when feeding" flag
11635 {
11636 7 removeItemsOfFamily(game,itemsbuf,itype_bait);
11637 7 verifyBothWeapons();
11638 7 }
11639 7 sfx(tmpscr->secretsfx);
11640 7 return false;
11641 }
11642
11643 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
11644 break;
11645 }
11646
11647 case itype_brang:
11648 {
11649
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 8673 times.
8962 if(Lwpns.idCount(wBrang) > itm.misc2)
11650 289 return false;
11651
11652
2/4
✓ Branch 0 taken 8673 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8673 times.
8673 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11653 {
11654 return item_error();
11655 }
11656
11657 8673 paymagiccost(itemid);
11658 8673 current_item_power(itype_brang);
11659
6/12
✓ Branch 0 taken 8673 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8673 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8673 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8673 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8673 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8673 times.
✗ Branch 11 not taken.
8673 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
11660 }
11661 8673 break;
11662
11663 case itype_hookshot:
11664 case itype_switchhook:
11665 {
11666
2/4
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225 times.
225 if(inlikelike || Lwpns.idCount(wHookshot))
11667 return false;
11668
11669
2/4
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225 times.
225 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11670 {
11671 return item_error();
11672 }
11673 225 bool sw = itm.family == itype_switchhook;
11674
11675
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
225 if(sw && (itm.flags&ITEM_FLAG8))
11676 switchhook_cost_item = itemid;
11677 225 else paymagiccost(itemid);
11678
11679 225 bool use_hookshot=true;
11680 225 bool hit_hs = false, hit_solid = false, insta_switch = false;
11681
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 222 times.
225 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11682 225 int32_t cpos = -1, ffcpos = -1;
11683
4/4
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 243 times.
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 225 times.
468 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
11684 {
11685
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 49 times.
243 if(dir==up)
11686 {
11687
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 1 times.
49 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
11688 1 hit_hs = true;
11689 49 }
11690
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 155 times.
194 else if(dir==down)
11691 {
11692
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
11693 hit_hs = true;
11694 39 }
11695
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 89 times.
155 else if(dir==left)
11696 {
11697
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
11698 hit_hs = true;
11699 66 }
11700
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 else if(dir==right)
11701 {
11702
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
11703 hit_hs = true;
11704 89 }
11705 //Diagonal Hookshot (6)
11706 else if(dir==r_down)
11707 {
11708 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11709 hit_hs = true;
11710 }
11711 else if(dir==l_down)
11712 {
11713 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11714 hit_hs = true;
11715 }
11716 else if(dir==r_up)
11717 {
11718 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11719 hit_hs = true;
11720 }
11721 else if(dir==l_up)
11722 {
11723 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11724 hit_hs = true;
11725 }
11726 243 }
11727
8/10
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 44 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 223 times.
✓ Branch 9 taken 2 times.
225 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
11728 2 hit_solid = true;
11729
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1 times.
225 if(hit_hs)
11730 {
11731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(sw)
11732 insta_switch = true; //switch immediately
11733 1 else use_hookshot = false; //No hooking against grabbable
11734 1 }
11735
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 223 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
225 if(hit_solid && !insta_switch)
11736 2 use_hookshot = false;
11737
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 222 times.
225 if(use_hookshot)
11738 {
11739 222 int32_t hookitem = itm.fam_type;
11740 222 int32_t hookpower = itm.power;
11741 222 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
11742
11743
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!Lwpns.has_space())
11744 {
11745 Lwpns.del(0);
11746 }
11747
11748
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!Lwpns.has_space(2))
11749 {
11750 Lwpns.del(0);
11751 }
11752
11753
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
222 switch(dir)
11754 {
11755 case up:
11756 {
11757 46 hookshot_used=true;
11758 46 hs_switcher = sw;
11759
4/8
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✗ Branch 7 not taken.
92 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11760
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
46 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11761 46 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11762
5/10
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 46 times.
✗ Branch 9 not taken.
92 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
11763
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
46 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11764 46 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11765 46 hs_startx=wx;
11766 46 hs_starty=wy-4;
11767 }
11768 46 break;
11769
11770 case down:
11771 {
11772 39 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11773 39 hookshot_used=true;
11774 39 hs_switcher = sw;
11775
5/10
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
78 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11776
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11777 39 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11778
5/10
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
78 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11779
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11780 39 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11781 39 hs_startx=wx;
11782 39 hs_starty=wy;
11783 }
11784 39 break;
11785
11786 case left:
11787 {
11788 54 hookshot_used=true;
11789 54 hs_switcher = sw;
11790
4/8
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
108 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11791
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11792 54 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11793
4/8
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
108 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11794
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11795 54 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11796 54 hs_startx=wx-4;
11797 54 hs_starty=wy;
11798 }
11799 54 break;
11800
11801 case right:
11802 {
11803 83 hookshot_used=true;
11804 83 hs_switcher = sw;
11805
4/8
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 83 times.
✗ Branch 7 not taken.
166 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11806
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11807 83 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11808
4/8
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 83 times.
✗ Branch 7 not taken.
166 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11809
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11810 83 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11811 83 hs_startx=wx+4;
11812 83 hs_starty=wy;
11813 }
11814 83 break;
11815 //Diagonal Hookshot (7)
11816 case r_down:
11817 {
11818 hookshot_used=true;
11819 hs_switcher = sw;
11820 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11821 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11822 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11823 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11824 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11825 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11826 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11827 hs_startx=wx+4;
11828 hs_starty=wy;
11829 }
11830 break;
11831
11832 case r_up:
11833 {
11834 hookshot_used=true;
11835 hs_switcher = sw;
11836 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11837 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11838 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11839 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11840 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11841 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11842 hs_startx=wx+4;
11843 hs_starty=wy;
11844 }
11845 break;
11846
11847 case l_down:
11848 {
11849 hookshot_used=true;
11850 hs_switcher = sw;
11851 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11852 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11853 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11854 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11855 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11856 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11857 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11858 hs_startx=wx+4;
11859 hs_starty=wy;
11860 }
11861 break;
11862
11863 case l_up:
11864 {
11865 hookshot_used=true;
11866 hs_switcher = sw;
11867 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11868 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11869 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11870 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11871 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11872 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11873 hs_startx=wx+4;
11874 hs_starty=wy;
11875 }
11876 break;
11877 }
11878 222 hookshot_frozen=true;
11879 222 }
11880
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(insta_switch)
11881 {
11882 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
11883 if (cpos > -1) hooked_combopos = cpos;
11884 if (ffcpos > -1)
11885 {
11886 switching_object = &(tmpscr->ffcs[ffcpos]);
11887 switching_object->switch_hooked = true;
11888 }
11889 w->misc=2;
11890 w->step=0;
11891 doSwitchHook(itm.misc5);
11892 if(itm.usesound2)
11893 sfx(itm.usesound2,pan(int32_t(x)));
11894 else if(QMisc.miscsfx[sfxSWITCHED])
11895 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
11896 stop_sfx(itm.usesound);
11897 }
11898 }
11899 225 break;
11900
11901 case itype_divinefire:
11902 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11903 return false;
11904
11905 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11906 {
11907 return item_error();
11908 }
11909
11910 paymagiccost(itemid);
11911 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11912 else {action=casting; FFCore.setHeroAction(casting);}
11913 magicitem=itemid;
11914 break;
11915
11916 case itype_divineescape:
11917 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11918 return false;
11919
11920 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11921 {
11922 return item_error();
11923 }
11924
11925 paymagiccost(itemid);
11926 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11927 else {action=casting; FFCore.setHeroAction(casting);}
11928 magicitem=itemid;
11929 break;
11930
11931 case itype_divineprotection:
11932 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11933 return false;
11934
11935 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11936 {
11937 return item_error();
11938 }
11939
11940 paymagiccost(itemid);
11941 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11942 else {action=casting; FFCore.setHeroAction(casting);}
11943 magicitem=itemid;
11944 break;
11945
11946 case itype_cbyrna:
11947 {
11948 //Beams already deployed
11949
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(Lwpns.idCount(wCByrna))
11950 {
11951 2 stopCaneOfByrna();
11952 2 return false;
11953 }
11954
11955
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11956 {
11957 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
11958 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
11959 return false;
11960 }
11961
11962 2 paymagiccost(itemid);
11963 2 last_cane_of_byrna_item_id = itemid;
11964 //zprint("itm.misc3: %d\n", itm.misc3);
11965
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for(int32_t i=0; i<itm.misc3; i++)
11966 {
11967 //byrna weapons are added here
11968 //space them apart
11969 //zprint("Added byrna weapon %d.\n", i);
11970 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
11971 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
11972
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11973 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11974 //wx += cos(2 * PI / (itm.misc3-i));
11975 //wy += sin(2 * PI / (itm.misc3-i));
11976 2 }
11977
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(Lwpns.idCount(wCByrna)))
11978 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
11979 }
11980 2 break;
11981
11982 case itype_clock:
11983 {
11984 ret = false;
11985 if(!(itm.flags & ITEM_FLAG1))
11986 break; //Passive clock, don't use
11987 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
11988 break;
11989 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
11990 {
11991 return item_error();
11992 }
11993
11994 paymagiccost(itemid);
11995
11996 setClock(watch=true);
11997
11998 for(int32_t i=0; i<eMAXGUYS; i++)
11999 clock_zoras[i]=0;
12000
12001 clockclk=itm.misc1;
12002 sfx(itm.usesound);
12003 break;
12004 }
12005 case itype_killem:
12006 {
12007 ret = false;
12008 if(!(itm.flags & ITEM_FLAG1))
12009 break; //Passive killemall, don't use
12010
12011 if(!(checkbunny(itemid) && checkmagiccost(itemid))
12012 || !can_kill_em_all()) //No enemies onscreen
12013 {
12014 return item_error();
12015 }
12016
12017 paymagiccost(itemid);
12018
12019 kill_em_all();
12020 sfx(itm.usesound);
12021 break;
12022 }
12023 case itype_refill:
12024 {
12025 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12026 {
12027 return item_error();
12028 }
12029
12030 bool did_something = false;
12031
12032 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
12033 {
12034 if(swordclk)
12035 did_something = true;
12036 swordclk = 0;
12037 verifyAWpn();
12038 }
12039 for(auto q = 0; q < 5; ++q)
12040 {
12041 auto ctr = itm.misc(q);
12042 if(unsigned(ctr) >= MAX_COUNTERS)
12043 continue;
12044 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
12045 if(!amnt) continue;
12046 bool gradual = itm.flags & ITEM_FLAG2;
12047 if(amnt > 0)
12048 {
12049 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
12050 {
12051 //Can't *do* anything... skip
12052 continue;
12053 }
12054 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
12055 {
12056 //Can't do anything unless affecting dcounter
12057 gradual = true;
12058 }
12059 }
12060 else //Negative
12061 {
12062 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
12063 {
12064 //Can't *do* anything... skip
12065 continue;
12066 }
12067 if(game->get_counter(ctr) <= 0)
12068 {
12069 //Can't do anything unless affecting dcounter
12070 gradual = true;
12071 }
12072 }
12073 did_something = true;
12074 if(gradual) //Gradual
12075 {
12076 game->change_dcounter(amnt, ctr);
12077 }
12078 else
12079 {
12080 game->change_counter(amnt, ctr);
12081 }
12082 }
12083 if(!did_something)
12084 {
12085 return item_error();
12086 }
12087 paymagiccost(itemid);
12088 sfx(itm.usesound);
12089 ret = false;
12090 break;
12091 }
12092
12093 default:
12094 1163 ret = false;
12095 1163 }
12096
12097
2/2
✓ Branch 0 taken 24544 times.
✓ Branch 1 taken 23 times.
24567 if(itm.flags & ITEM_DOWNGRADE)
12098 {
12099 23 game->set_item(itemid,false);
12100
12101 // Maybe Item Override has allowed the same item in both slots?
12102
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Bwpn == itemid)
12103 {
12104 Bwpn = 0;
12105 game->forced_bwpn = -1;
12106 verifyBWpn();
12107 }
12108
12109
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Awpn == itemid)
12110 {
12111 Awpn = 0;
12112 game->forced_awpn = -1;
12113 verifyAWpn();
12114 }
12115
12116
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Xwpn == itemid)
12117 {
12118 Xwpn = 0;
12119 game->forced_xwpn = -1;
12120 verifyXWpn();
12121 }
12122
12123
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Ywpn == itemid)
12124 {
12125 Ywpn = 0;
12126 game->forced_ywpn = -1;
12127 verifyYWpn();
12128 }
12129 23 }
12130
12131 24567 return ret;
12132 28377 }
12133
12134
12135 886228 bool HeroClass::doattack()
12136 {
12137
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 886228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
886228 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
12138 return false;
12139 //int32_t s = BSZ ? 0 : 11;
12140 886228 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
12141
12142
3/4
✓ Branch 0 taken 31486 times.
✓ Branch 1 taken 854742 times.
✓ Branch 2 taken 31486 times.
✗ Branch 3 not taken.
886228 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
12143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 886228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
886228 if(attack==wBugNet && bugnetid!=-1)
12144 {
12145 if(++attackclk >= NET_CLK_TOTAL)
12146 return false;
12147
12148 return true;
12149 }
12150
12151 // Abort attack if attackclk has run out and:
12152 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
12153 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
12154
12155
6/6
✓ Branch 0 taken 60802 times.
✓ Branch 1 taken 825426 times.
✓ Branch 2 taken 48533 times.
✓ Branch 3 taken 12269 times.
✓ Branch 4 taken 2287 times.
✓ Branch 5 taken 3601 times.
892116 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12156
12/12
✓ Branch 0 taken 40628 times.
✓ Branch 1 taken 7905 times.
✓ Branch 2 taken 3586 times.
✓ Branch 3 taken 37042 times.
✓ Branch 4 taken 43414 times.
✓ Branch 5 taken 5119 times.
✓ Branch 6 taken 42645 times.
✓ Branch 7 taken 769 times.
✓ Branch 8 taken 3585 times.
✓ Branch 9 taken 2303 times.
✓ Branch 10 taken 2264 times.
✓ Branch 11 taken 1321 times.
48533 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12157 {
12158 46246 tapping=false;
12159 46246 return false;
12160 }
12161
12162
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 839261 times.
839982 if(attackclk>29)
12163 {
12164 721 tapping=false;
12165 721 return false;
12166 }
12167
12168
4/4
✓ Branch 0 taken 29499 times.
✓ Branch 1 taken 809762 times.
✓ Branch 2 taken 27699 times.
✓ Branch 3 taken 1800 times.
839261 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
12169
3/4
✓ Branch 0 taken 29499 times.
✓ Branch 1 taken 809762 times.
✓ Branch 2 taken 29499 times.
✗ Branch 3 not taken.
839261 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12170 // An attack can be "walked out-of" after 8 frames, unless it's:
12171 // * a sword stab
12172 // * a hammer pound
12173 // * a wand thrust
12174 // * a candle thrust
12175 // * a cane thrust
12176 // In which case it should continue.
12177
8/8
✓ Branch 0 taken 43731 times.
✓ Branch 1 taken 795530 times.
✓ Branch 2 taken 105688 times.
✓ Branch 3 taken 61957 times.
✓ Branch 4 taken 741540 times.
✓ Branch 5 taken 115947 times.
✓ Branch 6 taken 185575 times.
✓ Branch 7 taken 555965 times.
1002727 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12178
5/6
✓ Branch 0 taken 163496 times.
✓ Branch 1 taken 22079 times.
✓ Branch 2 taken 13177 times.
✓ Branch 3 taken 150319 times.
✓ Branch 4 taken 13177 times.
✗ Branch 5 not taken.
185575 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12179
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 150289 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
163496 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12180
2/2
✓ Branch 0 taken 163466 times.
✓ Branch 1 taken 13177 times.
150319 && (attack != wBugNet) && attackclk>7))
12181 {
12182
8/8
✓ Branch 0 taken 54946 times.
✓ Branch 1 taken 2832 times.
✓ Branch 2 taken 52594 times.
✓ Branch 3 taken 2352 times.
✓ Branch 4 taken 49849 times.
✓ Branch 5 taken 2745 times.
✓ Branch 6 taken 2921 times.
✓ Branch 7 taken 46928 times.
269154 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
12183 {
12184 10850 lstep = s;
12185 10850 return false;
12186 }
12187 46928 }
12188
12189
2/2
✓ Branch 0 taken 1916 times.
✓ Branch 1 taken 765387 times.
767303 if(charging==0)
12190 {
12191 765387 lstep=0;
12192 765387 }
12193
12194 // Work out the sword charge-up delay
12195 767303 int32_t magiccharge = 192, normalcharge = 64;
12196 767303 int32_t itemid = current_item_id(itype_chargering);
12197
12198
2/2
✓ Branch 0 taken 728236 times.
✓ Branch 1 taken 39067 times.
767303 if(itemid>=0)
12199 {
12200 39067 normalcharge = itemsbuf[itemid].misc1;
12201 39067 magiccharge = itemsbuf[itemid].misc2;
12202 39067 }
12203
12204 767303 int scrollid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12205 767303 int scroll2id = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12206
12207 767303 bool doCharge=true;
12208
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 767303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
767303 if(z!=0 && fakez != 0)
12209 doCharge=false;
12210
2/2
✓ Branch 0 taken 555965 times.
✓ Branch 1 taken 211338 times.
767303 if(attack==wSword)
12211 {
12212
4/4
✓ Branch 0 taken 1661 times.
✓ Branch 1 taken 554304 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1637 times.
555965 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12213 554328 doCharge=false;
12214
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 1220 times.
1637 else if(charging<=normalcharge)
12215 {
12216
3/6
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1220 times.
✗ Branch 5 not taken.
1220 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12217 doCharge=false;
12218 1220 }
12219 555965 }
12220
2/2
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 189259 times.
211338 else if(attack==wHammer)
12221 {
12222
4/4
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 21330 times.
✓ Branch 2 taken 740 times.
✓ Branch 3 taken 9 times.
22079 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12223 22070 doCharge=false;
12224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(charging<=normalcharge)
12225 {
12226
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
9 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12227 1 doCharge=false;
12228 9 }
12229 22079 }
12230 else
12231 189259 doCharge=false;
12232
12233 // charging up weapon...
12234
2/2
✓ Branch 0 taken 1645 times.
✓ Branch 1 taken 765658 times.
767303 if(doCharge)
12235 {
12236 // Increase charging while holding down button.
12237
3/4
✓ Branch 0 taken 1645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1517 times.
1645 if(spins==0 && charging<magiccharge)
12238 1517 charging++;
12239
12240 // Once a charging threshold is reached, play the sound.
12241
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1636 times.
1645 if(charging==normalcharge)
12242 {
12243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!(itemsbuf[scrollid].flags&ITEM_FLAG1))
12244 9 paymagiccost(scrollid);
12245 9 sfx(itemsbuf[scrollid].usesound2,pan(x.getInt()));
12246 9 }
12247
2/2
✓ Branch 0 taken 1633 times.
✓ Branch 1 taken 3 times.
1636 else if(charging==magiccharge)
12248 {
12249
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(scroll2id>-1 && checkbunny(scroll2id) && checkmagiccost(scroll2id))
12250 {
12251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(itemsbuf[scroll2id].flags&ITEM_FLAG1))
12252 3 paymagiccost(scroll2id);
12253 3 charging++; // charging>magiccharge signifies a successful supercharge.
12254 3 sfx(itemsbuf[scroll2id].usesound2,pan(x.getInt()));
12255 3 }
12256 3 }
12257 1645 }
12258
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 765628 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
765658 else if(attack==wCByrna && byrnaid!=-1)
12259 {
12260
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!(itemsbuf[byrnaid].wpn))
12261 {
12262 attack = wNone;
12263 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12264 }
12265
12266 30 bool beamcount = false;
12267
12268
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 55 times.
81 for(int32_t i=0; i<Lwpns.Count(); i++)
12269 {
12270 55 weapon *w = ((weapon*)Lwpns.spr(i));
12271
12272
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 4 times.
55 if(w->id==wCByrna)
12273 {
12274 4 beamcount = true;
12275 4 break;
12276 }
12277 51 }
12278
12279 // If beams already deployed, remove them
12280
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
30 if(!attackclk && beamcount)
12281 {
12282 2 return startwpn(attackid); // Remove beams instantly
12283 }
12284
12285 // Otherwise, continue
12286 28 ++attackclk;
12287 28 }
12288 else
12289 {
12290 765628 ++attackclk;
12291
12292
6/6
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 764830 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 773 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 14 times.
765628 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12293 {
12294 14 ++attackclk; // Won't continue charging
12295 14 charging=0;
12296 14 }
12297
12298 // Faster if spinning.
12299
2/2
✓ Branch 0 taken 765036 times.
✓ Branch 1 taken 592 times.
765628 if(spins>0)
12300 592 ++attackclk;
12301
12302 // Even faster if hurricane spinning.
12303
2/2
✓ Branch 0 taken 765196 times.
✓ Branch 1 taken 432 times.
765628 if(spins>5)
12304 432 attackclk+=2;
12305
12306 // If at a charging threshold, do a charged attack.
12307
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 765514 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✓ Branch 5 taken 8 times.
765628 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12308 {
12309
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(attack==wSword)
12310 {
12311
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 bool super = charging>magiccharge && scroll2id > -1;
12312
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 int id = super ? scroll2id : scrollid;
12313 8 itemdata const& spinscroll = itemsbuf[id];
12314 8 bool paid = !(spinscroll.flags&ITEM_FLAG1);
12315
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8 if(!paid && checkbunny(id) && checkmagiccost(id))
12316 {
12317 paid = true;
12318 paymagiccost(id);
12319 }
12320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(paid)
12321 {
12322 8 currentscroll = id;
12323 8 spins=(spinscroll.misc1*4) + (super ? -3 : 1);
12324 8 attackclk=1;
12325 8 sfx(spinscroll.usesound,pan(x.getInt()));
12326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(spinscroll.flags&ITEM_FLAG1)
12327 paymagiccost(id);
12328 8 }
12329 8 }
12330 else if(attack==wHammer && sideviewhammerpound())
12331 {
12332 bool super = charging>magiccharge && scroll2id > -1;
12333 int id = super ? scroll2id : scrollid;
12334 itemdata const& quakescroll = itemsbuf[id];
12335 bool paid = !(quakescroll.flags&ITEM_FLAG1);
12336 if(!paid && checkbunny(id) && checkmagiccost(id))
12337 {
12338 paid = true;
12339 paymagiccost(id);
12340 }
12341 if(paid)
12342 {
12343 currentscroll = id;
12344 spins = super ? 2 : 1;
12345 sfx(quakescroll.usesound,pan(x.getInt()));
12346 quakeclk=quakescroll.misc1;
12347
12348 // general area stun
12349 for(int32_t i=0; i<GuyCount(); i++)
12350 {
12351 if(!isflier(GuyID(i)))
12352 {
12353 StunGuy(i,quakescroll.misc2-distance(x,y,GuyX(i),GuyY(i)));
12354 }
12355 }
12356
12357 int hmrid = (directWpn>-1 && itemsbuf[directWpn].family==itype_hammer) ? directWpn : current_item_id(itype_hammer);
12358 int hmrlvl = hmrid < 0 ? 1 : itemsbuf[hmrid].fam_type;
12359 if(hmrlvl < 1) hmrlvl = 1;
12360 int rad = quakescroll.misc2;
12361 for(int pos = 0; pos < 176; ++pos)
12362 {
12363 if(distance(x,y,COMBOX(pos),COMBOY(pos)) > rad) continue;
12364 for(int lyr = 0; lyr < 7; ++lyr)
12365 {
12366 int cid = FFCore.tempScreens[lyr]->data[pos];
12367 newcombo const& cmb = combobuf[cid];
12368 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
12369 {
12370 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
12371 ? hmrlvl <= cmb.triggerlevel
12372 : hmrlvl >= cmb.triggerlevel)
12373 do_trigger_combo(lyr,pos);
12374 }
12375 }
12376 }
12377 word c = tmpscr->numFFC();
12378 for(int ff = 0; ff < c; ++ff)
12379 {
12380 ffcdata& ffc = tmpscr->ffcs[ff];
12381 newcombo const& cmb = combobuf[ffc.getData()];
12382 if(distance(x,y,ffc.x,ffc.y) > rad) continue;
12383 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
12384 {
12385 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
12386 ? hmrlvl <= cmb.triggerlevel
12387 : hmrlvl >= cmb.triggerlevel)
12388 do_trigger_combo_ffc(ff);
12389 }
12390 }
12391 }
12392 }
12393 8 }
12394
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 765505 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 48 times.
765620 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12395 48 charging++;
12396
12397
7/8
✓ Branch 0 taken 12950 times.
✓ Branch 1 taken 752678 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 752678 times.
✓ Branch 4 taken 21500 times.
✓ Branch 5 taken 731178 times.
✓ Branch 6 taken 450851 times.
✓ Branch 7 taken 314777 times.
765628 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12398 314777 charging=0;
12399
12400
2/2
✓ Branch 0 taken 757529 times.
✓ Branch 1 taken 8099 times.
765628 if(attackclk>=SWORDCHARGEFRAME)
12401 8099 tapping = false;
12402 }
12403
12404
6/8
✓ Branch 0 taken 60489 times.
✓ Branch 1 taken 706812 times.
✓ Branch 2 taken 1087 times.
✓ Branch 3 taken 59402 times.
✓ Branch 4 taken 1087 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1087 times.
767301 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12405 {
12406 1087 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12407 }
12408
12409 766214 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12410
12411
11/14
✓ Branch 0 taken 718793 times.
✓ Branch 1 taken 47421 times.
✓ Branch 2 taken 54827 times.
✓ Branch 3 taken 663966 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 54795 times.
✓ Branch 6 taken 32 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
766214 if(attackclk==13 || (attackclk==7 && spins>1 && attack != wHammer && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12412 {
12413
12414
4/4
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 45430 times.
✓ Branch 2 taken 578 times.
✓ Branch 3 taken 1425 times.
47433 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12415
2/2
✓ Branch 0 taken 47415 times.
✓ Branch 1 taken 18 times.
47433 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12416
12417
4/4
✓ Branch 0 taken 47415 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 3683 times.
✓ Branch 3 taken 43732 times.
47433 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
12418 {
12419 43732 templife=templife*game->get_maxlife();
12420 43732 templife=templife/100;
12421 43732 }
12422 else
12423 {
12424 3701 templife*=game->get_hp_per_heart();
12425 }
12426
12427
2/2
✓ Branch 0 taken 17178 times.
✓ Branch 1 taken 30255 times.
47433 bool normalbeam = (int64_t(game->get_life())+(get_bit(quest_rules,qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12428 47433 int32_t perilid = current_item_id(itype_perilscroll);
12429
3/4
✓ Branch 0 taken 1637 times.
✓ Branch 1 taken 45796 times.
✓ Branch 2 taken 1637 times.
✗ Branch 3 not taken.
47436 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12430
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1634 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
1637 && checkbunny(perilid) && checkmagiccost(perilid)
12431 // Must actually be able to shoot sword beams
12432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
12433
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12434
12435
4/4
✓ Branch 0 taken 38509 times.
✓ Branch 1 taken 8924 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 38490 times.
47433 if(attack==wSword && !tapping)
12436 {
12437
4/4
✓ Branch 0 taken 38487 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 13307 times.
✓ Branch 3 taken 25180 times.
38490 if(perilbeam || normalbeam)
12438 {
12439
1/2
✓ Branch 0 taken 13310 times.
✗ Branch 1 not taken.
13310 if(attackclk==7)
12440 paymagiccost(crossid); // Pay the Cross Beams magic cost.
12441
12442
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13307 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
13310 if(perilbeam && !normalbeam)
12443 3 paymagiccost(perilid); // Pay the Peril Beam magic cost.
12444
12445 // TODO: Something that would be cheap but disgraceful to hack in at this point is
12446 // a way to make the peril/cross beam item's power stat influence the strength
12447 // of the peril/cross beam...
12448 13310 startwpn(attackid);
12449 13310 }
12450 25180 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12451 38490 }
12452
12453
2/2
✓ Branch 0 taken 45898 times.
✓ Branch 1 taken 1535 times.
47433 if(attack==wWand)
12454 1535 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
12455
12456
4/6
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 46641 times.
✓ Branch 2 taken 792 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 792 times.
✗ Branch 5 not taken.
47433 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
12457 startwpn(attackid);
12458
12459
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 47431 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
47433 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
12460 2 startwpn(attackid);
12461 47433 }
12462
12463
2/2
✓ Branch 0 taken 719280 times.
✓ Branch 1 taken 46934 times.
766214 if(attackclk==14)
12464 46934 lstep = s;
12465
12466 766214 return true;
12467 825120 }
12468
12469 12232992 bool HeroClass::can_attack()
12470 {
12471
4/4
✓ Branch 0 taken 12023662 times.
✓ Branch 1 taken 209330 times.
✓ Branch 2 taken 7185686 times.
✓ Branch 3 taken 4837976 times.
12232992 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
12472
4/6
✓ Branch 0 taken 12232992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12104588 times.
✓ Branch 3 taken 128404 times.
✓ Branch 4 taken 12104588 times.
✗ Branch 5 not taken.
13082978 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
12473
5/8
✓ Branch 0 taken 12104588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12104588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12104588 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12102892 times.
✓ Branch 7 taken 1696 times.
12104588 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
12474
3/4
✓ Branch 0 taken 12102892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10531297 times.
✓ Branch 3 taken 1571595 times.
12102892 || ((action==attacking||action==sideswimattacking)
12475
2/2
✓ Branch 0 taken 425000 times.
✓ Branch 1 taken 11677892 times.
12102892 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
12476
2/2
✓ Branch 0 taken 12102878 times.
✓ Branch 1 taken 424986 times.
12102892 && charging!=0))
12477 {
12478 980086 return false;
12479 }
12480
12481 12102878 int32_t r = (isdungeon()) ? 16 : 0;
12482 12102878 int32_t r2 = get_bit(quest_rules, qr_NOBORDER) ? 0 : 8;
12483
12484
4/5
✓ Branch 0 taken 3377958 times.
✓ Branch 1 taken 8724920 times.
✓ Branch 2 taken 3846284 times.
✓ Branch 3 taken 4878636 times.
✗ Branch 4 not taken.
12102878 if(!get_bit(quest_rules, qr_ITEMSONEDGES)) switch(dir)
12485 {
12486 case up:
12487 case down:
12488
2/2
✓ Branch 0 taken 3695346 times.
✓ Branch 1 taken 150938 times.
3846284 return !(y<(r2+r) || y>(160-r-r2));
12489
12490 case left:
12491 case right:
12492
2/2
✓ Branch 0 taken 4725154 times.
✓ Branch 1 taken 153482 times.
4878636 return !(x<(r2+r) || x>(240-r-r2));
12493 }
12494
12495 3377958 return true;
12496 13082964 }
12497
12498 8884 bool isRaftFlag(int32_t flag)
12499 {
12500
4/4
✓ Branch 0 taken 4567 times.
✓ Branch 1 taken 4317 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 4345 times.
8884 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
12501 }
12502
12503 3699839 void handle_lens_triggers(int32_t l_id)
12504 {
12505
2/2
✓ Branch 0 taken 3693580 times.
✓ Branch 1 taken 6259 times.
3699839 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
12506
2/2
✓ Branch 0 taken 25898873 times.
✓ Branch 1 taken 3699839 times.
29598712 for(auto layer = 0; layer < 7; ++layer)
12507 {
12508 25898873 mapscr* tmp = FFCore.tempScreens[layer];
12509
2/2
✓ Branch 0 taken 4558201648 times.
✓ Branch 1 taken 25898873 times.
4584100521 for(auto pos = 0; pos < 176; ++pos)
12510 {
12511 4558201648 newcombo const& cmb = combobuf[tmp->data[pos]];
12512
4/4
✓ Branch 0 taken 280896 times.
✓ Branch 1 taken 4557920752 times.
✓ Branch 2 taken 4558201462 times.
✓ Branch 3 taken 186 times.
4558201648 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12513 4557920752 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12514 {
12515 186 do_trigger_combo(layer, pos);
12516 186 }
12517 4558201648 }
12518 25898873 }
12519
2/2
✓ Branch 0 taken 144007 times.
✓ Branch 1 taken 3555832 times.
3699839 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
12520 {
12521 144007 word c = tmpscr->numFFC();
12522
2/2
✓ Branch 0 taken 619835 times.
✓ Branch 1 taken 144007 times.
763842 for(word i=0; i<c; i++)
12523 {
12524 619835 ffcdata& ffc = tmpscr->ffcs[i];
12525 619835 newcombo const& cmb = combobuf[ffc.getData()];
12526
3/4
✓ Branch 0 taken 1596 times.
✓ Branch 1 taken 618239 times.
✓ Branch 2 taken 619835 times.
✗ Branch 3 not taken.
619835 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12527 618239 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12528 {
12529 do_trigger_combo_ffc(i);
12530 }
12531 619835 }
12532 144007 }
12533 3699839 }
12534
12535 6186808 void do_lens()
12536 {
12537
2/2
✓ Branch 0 taken 2486969 times.
✓ Branch 1 taken 3699839 times.
6186808 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
12538 {
12539 2486969 do_210_lens();
12540 2486969 return;
12541 }
12542
12543 3699839 int32_t wpnPressed = getWpnPressed(itype_lens);
12544
6/6
✓ Branch 0 taken 6256 times.
✓ Branch 1 taken 3693583 times.
✓ Branch 2 taken 375 times.
✓ Branch 3 taken 3693208 times.
✓ Branch 4 taken 390142 times.
✓ Branch 5 taken 3303066 times.
3699839 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
12545
2/2
✓ Branch 0 taken 2769525 times.
✓ Branch 1 taken 930314 times.
3699839 if(itemid >= 0)
12546 {
12547
8/10
✓ Branch 0 taken 5343 times.
✓ Branch 1 taken 924971 times.
✓ Branch 2 taken 5343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 4650 times.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 527 times.
930314 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
12548 {
12549
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 209 times.
527 if(lensid<0)
12550 {
12551 209 lensid=itemid;
12552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(itemsbuf[itemid].family == itype_lens)
12553 209 Hero.setLastLensID(itemid);
12554
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 12 times.
209 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12555 209 }
12556
12557 527 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
12558
12559
2/10
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 527 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
527 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12560 {
12561 //clear the item script stack for a new script
12562 int i = itemid;
12563 FFCore.reset_script_engine_data(ScriptType::Item, i);
12564 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
12565 did_scriptl=true;
12566 }
12567
12568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12569 527 else lensclk = 12;
12570 527 }
12571 else
12572 {
12573 929787 did_scriptl=false;
12574
2/2
✓ Branch 0 taken 5732 times.
✓ Branch 1 taken 924055 times.
929787 if(!lensclk)
12575 {
12576
12577
2/2
✓ Branch 0 taken 923849 times.
✓ Branch 1 taken 206 times.
924055 if(lensid>-1)
12578 {
12579 206 lensid=-1;
12580 206 lensclk = 0;
12581
12582
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 11 times.
206 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12583 206 }
12584 924055 }
12585 }
12586 930314 }
12587 3699839 handle_lens_triggers(lensid);
12588 6186808 }
12589 //Add 2.10 version check to call this
12590 2486969 void do_210_lens()
12591 {
12592
3/4
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 2485289 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2485289 times.
2486969 int32_t itemid = lensid >= 0 ? lensid : directWpn>-1 ? directWpn : current_item_id(itype_lens);
12593
12594
2/2
✓ Branch 0 taken 367843 times.
✓ Branch 1 taken 2119126 times.
2486969 if(itemid<0)
12595 2119126 return;
12596
12597
6/8
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 366163 times.
✓ Branch 2 taken 1680 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✓ Branch 5 taken 1432 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 248 times.
367843 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
12598 {
12599
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 234 times.
248 if(lensid<0)
12600 {
12601 234 lensid=itemid;
12602
12603
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12604 234 }
12605
12606 248 paymagiccost(itemid, true);
12607
12608
2/10
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
248 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12609 {
12610 //clear the item script stack for a new script
12611 int i = itemid;
12612 FFCore.reset_script_engine_data(ScriptType::Item, i);
12613 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
12614 did_scriptl=true;
12615 }
12616
12617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12618 248 else lensclk = 12;
12619 248 }
12620 else
12621 {
12622 367595 did_scriptl=false;
12623
12624
6/8
✓ Branch 0 taken 1666 times.
✓ Branch 1 taken 365929 times.
✓ Branch 2 taken 1432 times.
✓ Branch 3 taken 234 times.
✓ Branch 4 taken 1432 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1432 times.
✗ Branch 7 not taken.
367595 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
12625 {
12626 234 lensid=-1;
12627 234 lensclk = 0;
12628
12629
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12630 234 }
12631 }
12632 2486969 }
12633
12634 6123 void HeroClass::do_hopping()
12635 {
12636 6123 do_lens();
12637
12638
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 5951 times.
6123 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
12639 //Possible fix for exiting water in diagonal movement. -Z
12640 {
12641 172 int32_t flippers_id = current_item_id(itype_flippers);
12642
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 169 times.
172 if(diveclk>0)
12643 {
12644 3 --diveclk;
12645
2/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
12646 {
12647 diveclk = itemsbuf[flippers_id].misc2;
12648 }
12649 3 }
12650
1/2
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
169 else if(DrunkrAbtn())
12651 {
12652 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
12653 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
12654
12655 if(global_diving==screen_diving)
12656 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
12657 }
12658
12659
3/8
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
172 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
12660 {
12661 172 SetSwim();
12662 172 hopclk = 0;
12663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172 times.
172 if (!IsSideSwim())
12664 {
12665 172 charging = attackclk = 0;
12666 172 tapping = false;
12667 172 }
12668 172 }
12669 else
12670 {
12671 herostep();
12672
12673 if(!isDiving() || (frame&1))
12674 {
12675 switch(dir)
12676 {
12677 case up:
12678 y -= 1;
12679 break;
12680
12681 case down:
12682 y += 1;
12683 break;
12684
12685 case left:
12686 x -= 1;
12687 break;
12688
12689 case right:
12690 x += 1;
12691 break;
12692 }
12693 }
12694 }
12695 172 }
12696 else // hopping in or out (need to separate the cases...)
12697 {
12698
4/6
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 5850 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5850 times.
5951 if((diagonalMovement||NO_GRIDLOCK))
12699 {
12700
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 73 times.
101 if(hopclk==1) //hopping out
12701 //>= 1 possible fix for getting stuck on land edges.
12702 //No, this is not a clock. it's a type. 1 == out, 2 == in.
12703 {
12704
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(hopdir!=-1) dir=hopdir;
12705
12706 73 landswim=0;
12707
12708
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 43 times.
73 if(dir==up)
12709 {
12710 43 herostep();
12711 43 herostep();
12712 43 int32_t sidestep=0;
12713
12714
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 43 times.
43 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12715 sidestep=1;
12716
3/6
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 43 times.
✗ Branch 5 not taken.
43 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12717 sidestep=2;
12718
12719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(sidestep==1) x++;
12720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 else if(sidestep==2) x--;
12721 43 else y--;
12722
12723
3/4
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 3 times.
43 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12724 {
12725 3 hopclk=0;
12726 3 diveclk=0;
12727 3 action=none; FFCore.setHeroAction(none);
12728 3 hopdir=-1;
12729 3 }
12730 43 }
12731
12732
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 30 times.
73 if(dir==down)
12733 {
12734 30 herostep();
12735 30 herostep();
12736 30 int32_t sidestep=0;
12737
12738
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
30 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12739 sidestep=1;
12740
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12741 sidestep=2;
12742
12743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(sidestep==1) x++;
12744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 else if(sidestep==2) x--;
12745 30 else y++;
12746
12747
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
30 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12748 {
12749 2 hopclk=0;
12750 2 diveclk=0;
12751 2 action=none; FFCore.setHeroAction(none);
12752 2 hopdir=-1;
12753 2 }
12754 30 }
12755
12756
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(dir==left)
12757 {
12758 herostep();
12759 herostep();
12760 int32_t sidestep=0;
12761
12762 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12763 sidestep=1;
12764 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12765 sidestep=2;
12766
12767 if(sidestep==1) y++;
12768 else if(sidestep==2) y--;
12769 else x--;
12770
12771 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12772 {
12773 hopclk=0;
12774 diveclk=0;
12775 action=none; FFCore.setHeroAction(none);
12776 hopdir=-1;
12777 }
12778 }
12779
12780
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(dir==right)
12781 {
12782 herostep();
12783 herostep();
12784 int32_t sidestep=0;
12785
12786 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12787 sidestep=1;
12788 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12789 sidestep=2;
12790
12791 if(sidestep==1) y++;
12792 else if(sidestep==2) y--;
12793 else x++;
12794
12795 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12796 {
12797 hopclk=0;
12798 diveclk=0;
12799 action=none; FFCore.setHeroAction(none);
12800 hopdir=-1;
12801 }
12802 }
12803 73 }
12804
12805
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 28 times.
101 if(hopclk==2) //hopping in
12806 {
12807 28 landswim=0;
12808
12809
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(dir==up)
12810 {
12811 14 herostep();
12812 14 herostep();
12813 14 int32_t sidestep=0;
12814
12815
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12816 sidestep=1;
12817
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
14 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12818 sidestep=2;
12819
12820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(sidestep==1) x++;
12821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(sidestep==2) x--;
12822 14 else y--;
12823
12824
3/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 1 times.
14 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12825 {
12826 1 hopclk=0xFF;
12827 1 diveclk=0;
12828 1 SetSwim();
12829 1 }
12830 14 }
12831
12832
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(dir==down)
12833 {
12834 herostep();
12835 herostep();
12836 int32_t sidestep=0;
12837
12838 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12839 sidestep=1;
12840 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12841 sidestep=2;
12842
12843 if(sidestep==1) x++;
12844 else if(sidestep==2) x--;
12845 else y++;
12846
12847 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12848 {
12849 hopclk=0xFF;
12850 diveclk=0;
12851 SetSwim();
12852 if (!IsSideSwim()) reset_swordcharge();
12853 }
12854 }
12855
12856
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(dir==left)
12857 {
12858 herostep();
12859 herostep();
12860 int32_t sidestep=0;
12861
12862 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12863 sidestep=1;
12864 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12865 sidestep=2;
12866
12867 if(sidestep==1) y++;
12868 else if(sidestep==2) y--;
12869 else x--;
12870
12871 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12872 {
12873 hopclk=0xFF;
12874 diveclk=0;
12875 SetSwim();
12876 }
12877 }
12878
12879
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(dir==right)
12880 {
12881 14 herostep();
12882 14 herostep();
12883
12884 14 int32_t sidestep=0;
12885
12886
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12887 sidestep=1;
12888
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
14 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12889 sidestep=2;
12890
12891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(sidestep==1) y++;
12892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(sidestep==2) y--;
12893 14 else x++;
12894
12895
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
14 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12896 {
12897 1 hopclk=0xFF;
12898 1 diveclk=0;
12899 1 SetSwim();
12900 1 }
12901 14 }
12902 28 }
12903
12904 101 }
12905 else
12906 {
12907
7/8
✓ Branch 0 taken 2193 times.
✓ Branch 1 taken 3657 times.
✓ Branch 2 taken 2193 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1624 times.
✓ Branch 5 taken 569 times.
✓ Branch 6 taken 310 times.
✓ Branch 7 taken 3347 times.
5850 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
12908 {
12909 569 action=none; FFCore.setHeroAction(none);
12910 569 hopclk = 0;
12911 569 diveclk = 0;
12912
12913
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 292 times.
569 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
12914 {
12915 // hopped in
12916 292 SetSwim();
12917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
292 if (!IsSideSwim()) attackclk = charging = spins = 0;
12918 292 }
12919 569 }
12920 else
12921 {
12922 5281 herostep();
12923 5281 herostep();
12924
12925
2/2
✓ Branch 0 taken 4972 times.
✓ Branch 1 taken 309 times.
5281 if(++hero_count>(16*hero_animation_speed))
12926 309 hero_count=0;
12927
12928 5281 int32_t xofs2 = x.getInt()&15;
12929 5281 int32_t yofs2 = y.getInt()&15;
12930 5281 int32_t s = 1 + (frame&1);
12931
12932
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 733 times.
✓ Branch 2 taken 1201 times.
✓ Branch 3 taken 1561 times.
✓ Branch 4 taken 1786 times.
5281 switch(dir)
12933 {
12934 case up:
12935
3/4
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 214 times.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
733 if(yofs2<3 || yofs2>13) --y;
12936 519 else y-=s;
12937
12938 733 break;
12939
12940 case down:
12941
4/4
✓ Branch 0 taken 999 times.
✓ Branch 1 taken 202 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 840 times.
1201 if(yofs2<3 || yofs2>13) ++y;
12942 840 else y+=s;
12943
12944 1201 break;
12945
12946 case left:
12947
4/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 260 times.
✓ Branch 3 taken 1105 times.
1561 if(xofs2<3 || xofs2>13) --x;
12948 1105 else x-=s;
12949
12950 1561 break;
12951
12952 case right:
12953
4/4
✓ Branch 0 taken 1485 times.
✓ Branch 1 taken 301 times.
✓ Branch 2 taken 237 times.
✓ Branch 3 taken 1248 times.
1786 if(xofs2<3 || xofs2>13) ++x;
12954 1248 else x+=s;
12955
12956 1786 break;
12957 }
12958 }
12959 }
12960 }
12961 6123 }
12962
12963 64189 void HeroClass::do_rafting()
12964 {
12965
12966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 if(toogam)
12967 {
12968 action=none; FFCore.setHeroAction(none);
12969 return;
12970 }
12971
12972 64189 FFCore.setHeroAction(rafting);
12973
12974 64189 do_lens();
12975
12976 64189 herostep();
12977
12978 //Calculate rafting speed
12979 64189 int32_t raft_item = current_item_id(itype_raft);
12980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
12981 64189 raft_step = vbound(raft_step, -8, 5);
12982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
12983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 if(raft_step < 0) raft_step = 1;
12984 64189 int32_t step_inc = 1 << (raft_step - 1);
12985 // Fix position
12986
1/2
✓ Branch 0 taken 64189 times.
✗ Branch 1 not taken.
64189 if(raft_step > 1)
12987 {
12988 if(x.getInt() & (step_inc-1))
12989 {
12990 x = x.getInt() & ~(step_inc-1);
12991 }
12992 if(y.getInt() & (step_inc-1))
12993 {
12994 y = y.getInt() & ~(step_inc-1);
12995 }
12996 }
12997 // Inc clock, check if we need to move this frame
12998 64189 ++raftclk;
12999
2/4
✓ Branch 0 taken 64189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64189 times.
64189 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
13000
13001
4/4
✓ Branch 0 taken 30394 times.
✓ Branch 1 taken 33795 times.
✓ Branch 2 taken 26029 times.
✓ Branch 3 taken 4365 times.
68441 if(!(x.getInt()&15) && !(y.getInt()&15))
13002 {
13003 // this sections handles switching to raft branches
13004
3/4
✓ Branch 0 taken 4144 times.
✓ Branch 1 taken 221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4144 times.
4365 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
13005 {
13006
7/8
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 120 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
221 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13007 {
13008 34 dir = up;
13009 34 goto skip;
13010 }
13011
13012
7/8
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
187 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13013 {
13014 34 dir = down;
13015 34 goto skip;
13016 }
13017
13018
7/8
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 94 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
153 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13019 {
13020 19 dir = left;
13021 19 goto skip;
13022 }
13023
13024
7/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
134 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13025 {
13026 26 dir = right;
13027 26 goto skip;
13028 }
13029 108 }
13030
2/4
✓ Branch 0 taken 4144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4144 times.
4144 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
13031 {
13032 if(dir == left) dir = right;
13033 else if(dir == right) dir = left;
13034 else if(dir == up) dir = down;
13035 else if(dir == down) dir = up;
13036 }
13037
13038
13039
3/4
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 3395 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 857 times.
4252 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
13040 {
13041
2/2
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 405 times.
857 if(dir<left) //going up or down
13042 {
13043
3/4
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
452 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13044 176 dir=right;
13045
3/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
276 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13046 160 dir=left;
13047
4/4
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 7 times.
116 else if(y>0 && y<160)
13048 {
13049 102 action=none; FFCore.setHeroAction(none);
13050 102 x = x.getInt();
13051 102 y = y.getInt();
13052 102 }
13053 452 }
13054 else //going left or right
13055 {
13056
3/4
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 239 times.
405 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13057 166 dir=down;
13058
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
239 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13059 162 dir=up;
13060
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 else if(x>0 && x<240)
13061 {
13062 77 action=none; FFCore.setHeroAction(none);
13063 77 x = x.getInt();
13064 77 y = y.getInt();
13065 77 }
13066 }
13067 857 }
13068 4252 }
13069
13070 skip:
13071
13072
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14264 times.
✓ Branch 2 taken 13696 times.
✓ Branch 3 taken 16866 times.
✓ Branch 4 taken 19363 times.
64189 switch(dir)
13073 {
13074 case up:
13075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14264 times.
14264 if(x.getInt()&15)
13076 {
13077 if(x.getInt()&8)
13078 x++;
13079 else x--;
13080 }
13081 14264 else y -= step_inc;
13082
13083 14264 break;
13084
13085 case down:
13086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13696 times.
13696 if(x.getInt()&15)
13087 {
13088 if(x.getInt()&8)
13089 x++;
13090 else x--;
13091 }
13092 13696 else y += step_inc;
13093
13094 13696 break;
13095
13096 case left:
13097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16866 times.
16866 if(y.getInt()&15)
13098 {
13099 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
13100 {
13101 if ((y.getInt() % 16) < 4) y--;
13102 else y++;
13103 }
13104 else
13105 {
13106 if(y.getInt()&8)
13107 y++;
13108 else y--;
13109 }
13110 }
13111 16866 else x -= step_inc;
13112
13113 16866 break;
13114
13115 case right:
13116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19363 times.
19363 if(y.getInt()&15)
13117 {
13118 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
13119 {
13120 if ((y.getInt() % 16) <= 4) y--;
13121 else y++;
13122 }
13123 else
13124 {
13125 if(y.getInt()&8)
13126 y++;
13127 else y--;
13128 }
13129 }
13130 19363 else x += step_inc;
13131
13132 19363 break;
13133 }
13134 64189 }
13135
13136 28 bool HeroClass::try_hover()
13137 {
13138
6/10
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
28 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
13139 {
13140 2 int32_t itemid = current_item_id(itype_hoverboots);
13141
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hoverclk < 0)
13142 hoverclk = -hoverclk;
13143 else
13144 {
13145 2 fall = fakefall = jumping = 0;
13146
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].misc1)
13147 2 hoverclk = itemsbuf[itemid].misc1;
13148 else
13149 {
13150 hoverclk = 1;
13151 hoverflags |= HOV_INF;
13152 }
13153
13154
13155 2 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
13156 }
13157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[itemid].wpn)
13158
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 decorations.add(new dHover(x, y, dHOVER, 0));
13159 2 return true;
13160 }
13161 26 return false;
13162 28 }
13163
13164 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
13165 //Returns '-1' if not being pulled
13166 //Returns '-2' if should be falling in
13167 23946635 int32_t HeroClass::check_pitslide(bool ignore_hover)
13168 {
13169 //Pitfall todo -Emily
13170 //Iron boots; can't fight slipping, 2px/frame
13171 //Scripted variables to read pull dir/clk (clk only for non-hero)
13172 //Implement falling for all sprite types (npc AI)
13173 // Fall/slipping tiles for enemies
13174 // Fall/slipping SFX for enemies
13175 // Fall SFX for items/weapons
13176 // Weapons/Misc sprite shared for falling items/weapons
13177 //Maybe slip SFX for Hero?
13178 // Weapons/Misc sprite override for falling sprite?
13179 //Update std.zh with relevant new stuff
13180
2/2
✓ Branch 0 taken 995903 times.
✓ Branch 1 taken 22950732 times.
23946635 if(can_pitfall(ignore_hover))
13181 {
13182
2/2
✓ Branch 0 taken 1784379 times.
✓ Branch 1 taken 21166353 times.
22950732 bool can_diag = (diagonalMovement || get_bit(quest_rules,qr_DISABLE_4WAY_GRIDLOCK));
13183 22950732 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
13184 22950732 int32_t ispitbl = getpitfall(x,y+15);
13185 22950732 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
13186 22950732 int32_t ispitbr = getpitfall(x+15,y+15);
13187 22950732 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
13188 22950732 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
13189 22950732 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
13190 22950732 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
13191 22950732 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
13192 22950732 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13193 22950732 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13194 22950732 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13195 static const int32_t flag_pit_irresistable = (1<<24);
13196
5/5
✓ Branch 0 taken 22943582 times.
✓ Branch 1 taken 1040 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 3139 times.
✓ Branch 4 taken 2862 times.
22950732 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13197 {
13198 1040 case 4: return -2; //Fully over pit; fall in
13199 case 3:
13200 {
13201
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
109 if(ispitul && ispitur && ispitbl) //UL_3
13202 {
13203
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(ispitul_50)
13204 {
13205
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13206 6 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13207 }
13208 }
13209
3/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 else if(ispitul && ispitur && ispitbr) //UR_3
13210 {
13211 if(ispitur_50)
13212 {
13213 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13214 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13215 }
13216 }
13217
4/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 83 times.
87 else if(ispitul && ispitbl && ispitbr) //BL_3
13218 {
13219
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 74 times.
83 if(ispitbl_50)
13220 {
13221
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
9 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13222 9 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13223 }
13224 74 }
13225
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 else if(ispitbl && ispitur && ispitbr) //BR_3
13226 {
13227
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(ispitbr_50)
13228 {
13229
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13230 4 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13231 }
13232 }
13233 74 break;
13234 }
13235 case 2:
13236 {
13237
4/4
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 1827 times.
✓ Branch 2 taken 1303 times.
✓ Branch 3 taken 9 times.
3139 if(ispitul && ispitur) //Up
13238 {
13239
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
9 if(DrunkDown())
13240 {
13241
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(ispitul_75 && ispitur_75) //Straight up
13242 {
13243 return up | flag_pit_irresistable | (ispitul << 8);
13244 }
13245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(ispitul_75)
13246 {
13247 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
13248 }
13249
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if(ispitur_75)
13250 {
13251 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
13252 }
13253 3 else return -1;
13254 }
13255 else
13256 {
13257
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(ispitul_50 && ispitur_50) //Straight up
13258 {
13259 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13260 }
13261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(ispitul_50)
13262 {
13263 if(DrunkRight() && !ispitul_75) return -1;
13264 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13265 }
13266
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(ispitur_50)
13267 {
13268 if(DrunkLeft() && !ispitur_75) return -1;
13269 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13270 }
13271 }
13272 6 }
13273
4/4
✓ Branch 0 taken 1683 times.
✓ Branch 1 taken 1447 times.
✓ Branch 2 taken 1303 times.
✓ Branch 3 taken 380 times.
3130 else if(ispitbl && ispitbr) //Down
13274 {
13275
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 368 times.
380 if(DrunkUp())
13276 {
13277
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(ispitbl_75 && ispitbr_75) //Straight down
13278 {
13279 return down | flag_pit_irresistable | (ispitbl << 8);
13280 }
13281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbl_75)
13282 {
13283 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
13284 }
13285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbr_75)
13286 {
13287 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
13288 }
13289 12 else return -1;
13290 }
13291 else
13292 {
13293
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 362 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
368 if(ispitbl_50 && ispitbr_50) //Straight down
13294 {
13295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
13296 }
13297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
362 else if(ispitbl_50)
13298 {
13299 if(DrunkRight() && !ispitbl_75) return -1;
13300 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13301 }
13302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
362 else if(ispitbr_50)
13303 {
13304 if(DrunkLeft() && !ispitbr_75) return -1;
13305 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13306 }
13307 }
13308 362 }
13309
3/4
✓ Branch 0 taken 1303 times.
✓ Branch 1 taken 1447 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1303 times.
2750 else if(ispitbl && ispitul) //Left
13310 {
13311
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1161 times.
1303 if(DrunkRight())
13312 {
13313
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
142 if(ispitul_75 && ispitbl_75) //Straight left
13314 {
13315 return left | flag_pit_irresistable | (ispitul << 8);
13316 }
13317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(ispitul_75)
13318 {
13319 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13320 }
13321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(ispitbl_75)
13322 {
13323 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13324 }
13325 142 else return -1;
13326 }
13327 else
13328 {
13329
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
1161 if(ispitul_50 && ispitbl_50) //Straight left
13330 {
13331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13332 }
13333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 else if(ispitul_50)
13334 {
13335 if(DrunkDown() && !ispitul_75) return -1;
13336 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13337 }
13338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 else if(ispitbl_50)
13339 {
13340 if(DrunkUp() && !ispitbl_75) return -1;
13341 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13342 }
13343 }
13344 1140 }
13345
2/4
✓ Branch 0 taken 1447 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1447 times.
1447 else if(ispitbr && ispitur) //Right
13346 {
13347
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 1318 times.
1447 if(DrunkLeft())
13348 {
13349
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
129 if(ispitur_75 && ispitbr_75) //Straight right
13350 {
13351 6 return right | flag_pit_irresistable | (ispitur << 8);
13352 }
13353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 else if(ispitur_75)
13354 {
13355 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13356 }
13357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 else if(ispitbr_75)
13358 {
13359 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13360 }
13361 123 else return -1;
13362 }
13363 else
13364 {
13365
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1214 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
1318 if(ispitur_50 && ispitbr_50) //Straight right
13366 {
13367
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 20 times.
104 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13368 }
13369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1214 times.
1214 else if(ispitur_50)
13370 {
13371 if(DrunkDown() && !ispitur_75) return -1;
13372 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13373 }
13374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1214 times.
1214 else if(ispitbr_50)
13375 {
13376 if(DrunkUp() && !ispitbr_75) return -1;
13377 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13378 }
13379 }
13380 1214 }
13381 2722 break;
13382 }
13383 case 1:
13384 {
13385
3/4
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 1921 times.
✓ Branch 2 taken 941 times.
✗ Branch 3 not taken.
2862 if(ispitul && ispitul_50) //UL_1
13386 {
13387 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13388 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13389 }
13390
4/4
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 2402 times.
✓ Branch 2 taken 444 times.
✓ Branch 3 taken 16 times.
2862 if(ispitur && ispitur_50) //UR_1
13391 {
13392
2/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13393 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13394 }
13395
3/4
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 332 times.
✗ Branch 3 not taken.
2846 if(ispitbl && ispitbl_50) //BL_1
13396 {
13397 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13398 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13399 }
13400
3/4
✓ Branch 0 taken 1129 times.
✓ Branch 1 taken 1717 times.
✓ Branch 2 taken 1129 times.
✗ Branch 3 not taken.
2846 if(ispitbr && ispitbr_50) //BR_1
13401 {
13402 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13403 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13404 }
13405 2846 break;
13406 }
13407 }
13408 22949224 }
13409 23945127 return -1;
13410 23946635 }
13411
13412 5356844 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13413 {
13414 5356844 pitfall();
13415
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5356840 times.
5356844 if(fallclk) return true;
13416 5356840 int32_t val = check_pitslide();
13417 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13418
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5356819 times.
5356840 if(val == -1)
13419 {
13420 5356819 pit_pulldir = -1;
13421 5356819 pit_pullclk = 0;
13422 5356819 return false;
13423 }
13424 21 int32_t dir = val&0xFF;
13425 21 int32_t cmbid = (val&0xFFFF00)>>8;
13426 21 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13428 {
13429 pit_pulldir = -1;
13430 pit_pullclk = 0;
13431 return false;
13432 }
13433
4/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 2 times.
21 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13434 {
13435 2 pit_pulldir = -1;
13436 2 pit_pullclk = 0;
13437 2 return false;
13438 }
13439 19 pit_pulldir = dir;
13440 19 int32_t step = 1;
13441
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 4 times.
19 if(sensitivity == 0)
13442 {
13443 4 step = 2;
13444 4 sensitivity = 1;
13445 4 }
13446
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 10 times.
19 if(pit_pullclk++ % sensitivity) //No pull this frame
13447 9 return (val&0x100);
13448
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 10 times.
23 for(; step > 0 && !fallclk; --step)
13449 {
13450
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
13 switch(dir)
13451 {
13452 case l_up: case l_down: case left:
13453 --x; break;
13454 case r_up: case r_down: case right:
13455 12 ++x; break;
13456 }
13457
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 12 times.
13 switch(dir)
13458 {
13459 case l_up: case r_up: case up:
13460 --y; break;
13461 case l_down: case r_down: case down:
13462 1 ++y; break;
13463 }
13464 13 pitfall();
13465 13 }
13466
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 return fallclk || (val&0x100);
13467 5356844 }
13468
13469 5357347 void HeroClass::pitfall()
13470 {
13471
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 5356857 times.
5357347 if(fallclk)
13472 {
13473 490 drop_liftwpn();
13474
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
490 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
13475 //Handle falling
13476
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 7 times.
490 if(!--fallclk)
13477 {
13478 7 std::vector<int32_t> &ev = FFCore.eventData;
13479 7 ev.clear();
13480 7 ev.push_back(fallCombo*10000);
13481
13482 7 throwGenScriptEvent(GENSCR_EVENT_PLAYER_FALL);
13483
13484 7 fallCombo = ev[0]/10000;
13485
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 if(fallCombo < 0 || fallCombo >= MAXCOMBOS)
13486 fallCombo = 0;
13487
13488 7 int32_t dmg = game->get_hp_per_heart()/4;
13489 7 bool dmg_perc = false;
13490 7 bool warp = false;
13491
13492 7 action=none; FFCore.setHeroAction(none);
13493
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
13494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(cmb)
13495 {
13496 7 dmg = cmb->attributes[0]/10000L;
13497 7 dmg_perc = cmb->usrflags&cflag3;
13498 7 warp = cmb->usrflags&cflag1;
13499 7 }
13500
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 if(cheat_superman && dmg > 0)
13501 dmg = 0;
13502
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(dmg) //Damage
13503 {
13504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
13505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
13506 3 }
13507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(warp) //Warp
13508 {
13509 sdir = dir;
13510 if(cmb->usrflags&cflag2) //Direct Warp
13511 {
13512 didpit=true;
13513 pitx=x;
13514 pity=y;
13515 }
13516 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
13517 }
13518 else //Reset to screen entry
13519 {
13520 7 go_respawn_point();
13521 }
13522 7 }
13523 490 }
13524
2/2
✓ Branch 0 taken 318802 times.
✓ Branch 1 taken 5038055 times.
5356857 else if(can_pitfall())
13525 {
13526 5038055 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
13527 5038055 bool ispitbl = ispitfall(x,y+15);
13528 5038055 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
13529 5038055 bool ispitbr = ispitfall(x+15,y+15);
13530 5038055 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
13531
9/10
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 5037570 times.
✓ Branch 2 taken 268 times.
✓ Branch 3 taken 217 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 258 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 7 times.
5038055 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
13532 {
13533
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
13534
3/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 4 times.
7 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
13535 7 fallclk = PITFALL_FALL_FRAMES;
13536 7 fallCombo = pitctr;
13537 7 action=falling; FFCore.setHeroAction(falling);
13538 7 spins = 0;
13539 7 charging = 0;
13540 7 drop_liftwpn();
13541 7 }
13542 5038055 }
13543 5357347 }
13544
13545 void HeroClass::mod_steps(std::vector<zfix*>& v)
13546 {
13547 bool can_combo = ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS);
13548 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1) && can_combo) ||
13549 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1));
13550 //!DIMITODO: add QR for slow combos under hero
13551 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
13552 {
13553 if(tmpscr2[i].valid!=0)
13554 {
13555 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
13556 {
13557 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
13558 {
13559 slowcombo = false;
13560 break;
13561 }
13562 }
13563 else
13564 {
13565 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
13566 {
13567 slowcombo = false;
13568 break;
13569 }
13570 }
13571 }
13572 }
13573 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
13574 bool is_swimming = (action == swimming);
13575 int32_t shieldid = getCurrentActiveShield();
13576 if(shieldid > -1)
13577 {
13578 itemdata const& shield = itemsbuf[shieldid];
13579 if(shield.flags & ITEM_FLAG10) //Change Speed flag
13580 {
13581 zfix perc = shield.misc7;
13582 perc /= 100;
13583 if(perc < 0)
13584 perc = (perc*-1)+1;
13585 zfix add(shield.misc8);
13586 add /= 100;
13587 for(zfix* stp : v)
13588 {
13589 zfix& pix = *stp;
13590 pix = (pix * perc) + add;
13591 }
13592 }
13593 }
13594
13595 auto slow_cpos = COMBOPOS(x+7,y+8);
13596 if(can_combo) for(int q = 6; q >= 0; --q)
13597 {
13598 mapscr* m = FFCore.tempScreens[q];
13599 if(!m->valid) continue;
13600 newcombo const& cmb = combobuf[m->data[slow_cpos]];
13601
13602 for(zfix* stp : v)
13603 {
13604 zfix& pix = *stp;
13605 pix *= cmb.speed_mult;
13606 if(cmb.speed_div)
13607 pix /= cmb.speed_div;
13608 pix += cmb.speed_add;
13609 }
13610 if(q > 0 && cmb.type == cBRIDGE)
13611 {
13612 if(get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS)
13613 ? !_walkflag_layer(x+7,y+8,1,&(tmpscr2[q-1]))
13614 : _effectflag_layer(x+7,y+8,1,&(tmpscr2[q-1])))
13615 {
13616 break; //Bridge blocks speed change from below it
13617 }
13618 }
13619 }
13620 zfix mult = 1, div = 1;
13621 if(is_swimming)
13622 {
13623 mult = game->swim_mult;
13624 div = game->swim_div;
13625 }
13626 else if(slowcharging && slowcombo) //1/2 speed
13627 {
13628 div = 2;
13629 }
13630 else if(slowcharging || slowcombo) //2/3 speed
13631 {
13632 mult = 2;
13633 div = 3;
13634 }
13635 if(!div) div = 1;
13636 if(mult != 1 || div != 1)
13637 {
13638 for(zfix* stp : v)
13639 {
13640 zfix& pix = *stp;
13641 pix = ((pix / div) * mult);
13642 }
13643 }
13644 }
13645
13646 6180506 void HeroClass::moveheroOld()
13647 {
13648
2/4
✓ Branch 0 taken 6180506 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6180506 times.
6180506 if(lstunclock || is_conveyor_stunned) return;
13649 6180506 int32_t xoff=x.getInt()&7;
13650 6180506 int32_t yoff=y.getInt()&7;
13651
3/4
✓ Branch 0 taken 6164706 times.
✓ Branch 1 taken 15800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6164706 times.
6180506 if(NO_GRIDLOCK)
13652 {
13653 15800 xoff = 0;
13654 15800 yoff = 0;
13655 15800 }
13656 6180506 int32_t push=pushing;
13657 6180506 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
13658 6180506 pushing=0;
13659 6180506 zfix temp_step(hero_newstep);
13660 6180506 zfix temp_x(x);
13661 6180506 zfix temp_y(y);
13662
13663 6180506 int32_t flippers_id = current_item_id(itype_flippers);
13664 6180506 itemdata const& itm = itemsbuf[flippers_id];
13665 6180506 byte intbtn = byte(itm.misc3&0xFF);
13666 6180506 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
13667 6180506 bool eatdive = false;
13668
2/2
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 6174987 times.
6180506 if(diveclk>0)
13669 {
13670
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5519 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5519 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
13671 5519 --diveclk;
13672
4/8
✓ Branch 0 taken 3688 times.
✓ Branch 1 taken 1831 times.
✓ Branch 2 taken 3688 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3688 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5519 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
13673 {
13674 diveclk = itemsbuf[flippers_id].misc2;
13675 eatdive = true;
13676 }
13677 5519 }
13678
4/4
✓ Branch 0 taken 59148 times.
✓ Branch 1 taken 6115839 times.
✓ Branch 2 taken 59060 times.
✓ Branch 3 taken 88 times.
6174987 else if(action == swimming && dive_pressed)
13679 {
13680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13681 88 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13682
13683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(global_diving==screen_diving)
13684 {
13685
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13686 88 eatdive = true;
13687 88 }
13688 88 }
13689
2/2
✓ Branch 0 taken 6180418 times.
✓ Branch 1 taken 88 times.
6180506 if(eatdive)
13690 88 getIntBtnInput(intbtn, true, true, false, false, false);
13691
13692
2/2
✓ Branch 0 taken 6116317 times.
✓ Branch 1 taken 64189 times.
6180506 if(action==rafting)
13693 {
13694 64189 do_rafting();
13695
13696
2/2
✓ Branch 0 taken 64010 times.
✓ Branch 1 taken 179 times.
64189 if(action==rafting)
13697 {
13698 64010 return;
13699 }
13700
13701
13702 179 set_respawn_point();
13703 179 trySideviewLadder();
13704 179 }
13705
13706 6116496 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
13707 6116496 int32_t btnwpn = -1;
13708
13709 //&0xFFF removes the "bow & arrows" bitmask
13710 //The Quick Sword is allowed to interrupt attacks.
13711
4/4
✓ Branch 0 taken 6011831 times.
✓ Branch 1 taken 104665 times.
✓ Branch 2 taken 3592854 times.
✓ Branch 3 taken 2418977 times.
6116496 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13712
8/8
✓ Branch 0 taken 5352770 times.
✓ Branch 1 taken 763726 times.
✓ Branch 2 taken 5347000 times.
✓ Branch 3 taken 5770 times.
✓ Branch 4 taken 215492 times.
✓ Branch 5 taken 554004 times.
✓ Branch 6 taken 33262 times.
✓ Branch 7 taken 736234 times.
6116496 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
13713 {
13714
2/2
✓ Branch 0 taken 15770 times.
✓ Branch 1 taken 5364492 times.
5380262 if(DrunkrBbtn())
13715 {
13716 15770 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
13717 15770 dowpn = Bwpn&0xFFF;
13718 15770 directWpn = directItemB;
13719 15770 }
13720
2/2
✓ Branch 0 taken 42606 times.
✓ Branch 1 taken 5321886 times.
5364492 else if(DrunkrAbtn())
13721 {
13722 42606 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
13723 42606 dowpn = Awpn&0xFFF;
13724 42606 directWpn = directItemA;
13725 42606 }
13726
4/4
✓ Branch 0 taken 71669 times.
✓ Branch 1 taken 5250217 times.
✓ Branch 2 taken 71662 times.
✓ Branch 3 taken 7 times.
5321886 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
13727 {
13728 7 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
13729 7 dowpn = Xwpn&0xFFF;
13730 7 directWpn = directItemX;
13731 7 }
13732
4/4
✓ Branch 0 taken 71662 times.
✓ Branch 1 taken 5250217 times.
✓ Branch 2 taken 71557 times.
✓ Branch 3 taken 105 times.
5321879 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
13733 {
13734 105 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
13735 105 dowpn = Ywpn&0xFFF;
13736 105 directWpn = directItemY;
13737 105 }
13738
13739
1/2
✓ Branch 0 taken 5380262 times.
✗ Branch 1 not taken.
5380262 if(directWpn > 255) directWpn = 0;
13740
13741 // The Quick Sword only allows repeated sword or wand swings.
13742
7/8
✓ Branch 0 taken 5347000 times.
✓ Branch 1 taken 33262 times.
✓ Branch 2 taken 33262 times.
✓ Branch 3 taken 5347000 times.
✓ Branch 4 taken 32749 times.
✓ Branch 5 taken 513 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5347513 times.
5380262 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
13743 32749 btnwpn=-1;
13744 5380262 }
13745
13746
2/2
✓ Branch 0 taken 317704 times.
✓ Branch 1 taken 5798792 times.
6116496 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
13747
11/12
✓ Branch 0 taken 5728289 times.
✓ Branch 1 taken 388207 times.
✓ Branch 2 taken 5482398 times.
✓ Branch 3 taken 245891 times.
✓ Branch 4 taken 5407782 times.
✓ Branch 5 taken 74616 times.
✓ Branch 6 taken 5364850 times.
✓ Branch 7 taken 42932 times.
✓ Branch 8 taken 40840 times.
✓ Branch 9 taken 5324010 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 40840 times.
6116496 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
13748 {
13749
2/2
✓ Branch 0 taken 1566 times.
✓ Branch 1 taken 39274 times.
40840 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
13750
5/6
✓ Branch 0 taken 40838 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 40823 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
40840 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
13751 {
13752
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40823 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40823 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
13753 {
13754 paymagiccost(attackid,true);
13755 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
13756 }
13757 40823 SetAttack();
13758 40823 attack=wSword;
13759
13760 40823 attackclk=0;
13761
2/2
✓ Branch 0 taken 1551 times.
✓ Branch 1 taken 39272 times.
40823 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
13762
13763
2/10
✓ Branch 0 taken 40823 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40823 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
40823 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13764 {
13765 if(!checkmagiccost(dowpn))
13766 {
13767 item_error();
13768 }
13769 else
13770 {
13771 //clear the item script stack for a new script
13772 int i = dowpn;
13773 FFCore.reset_script_engine_data(ScriptType::Item, i);
13774 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13775 did_scripta=true;
13776 }
13777 }
13778 40823 }
13779 else
13780 {
13781 17 item_error();
13782 }
13783 40840 }
13784 else
13785 {
13786 6075656 did_scripta=false;
13787 }
13788
13789
6/10
✓ Branch 0 taken 6052294 times.
✓ Branch 1 taken 64202 times.
✓ Branch 2 taken 6052294 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6052294 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6052294 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6052294 times.
6116496 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
13790 {
13791
3/4
✓ Branch 0 taken 976373 times.
✓ Branch 1 taken 5075921 times.
✓ Branch 2 taken 976373 times.
✗ Branch 3 not taken.
6052294 if(DrunkUp() && canSideviewLadder())
13792 {
13793 setOnSideviewLadder(true);
13794 }
13795
3/4
✓ Branch 0 taken 816932 times.
✓ Branch 1 taken 5235362 times.
✓ Branch 2 taken 816932 times.
✗ Branch 3 not taken.
6052294 else if(DrunkDown() && canSideviewLadder(true))
13796 {
13797 y+=1;
13798 setOnSideviewLadder(true);
13799 }
13800 6052294 }
13801
13802 6116496 int32_t wx=x;
13803 6116496 int32_t wy=y;
13804
3/6
✓ Branch 0 taken 4032687 times.
✓ Branch 1 taken 2083809 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6116496 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6116496 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13805 {
13806 if((xoff==0)||diagonalMovement)
13807 {
13808 if(DrunkUp()) dir=up;
13809 if(DrunkDown()) dir=down;
13810 }
13811
13812 if((yoff==0)||diagonalMovement)
13813 {
13814 if(DrunkLeft()) dir=left;
13815 if(DrunkRight()) dir=right;
13816 }
13817 }
13818
13819
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1412298 times.
✓ Branch 2 taken 1196459 times.
✓ Branch 3 taken 1673855 times.
✓ Branch 4 taken 1833884 times.
6116496 switch(dir)
13820 {
13821 case up:
13822 1412298 wy-=16;
13823 1412298 break;
13824
13825 case down:
13826 1196459 wy+=16;
13827 1196459 break;
13828
13829 case left:
13830 1673855 wx-=16;
13831 1673855 break;
13832
13833 case right:
13834 1833884 wx+=16;
13835 1833884 break;
13836 }
13837
13838 6116496 do_lens();
13839
13840 6116496 WalkflagInfo info;
13841
13842 6116496 bool no_jinx = true;
13843
7/8
✓ Branch 0 taken 5728289 times.
✓ Branch 1 taken 388207 times.
✓ Branch 2 taken 17010 times.
✓ Branch 3 taken 5711279 times.
✓ Branch 4 taken 17010 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1093 times.
✓ Branch 7 taken 15917 times.
6116496 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
13844 {
13845 15917 bool paidmagic = false;
13846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15917 times.
15917 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
13847
7/10
✓ Branch 0 taken 15917 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14381 times.
✓ Branch 3 taken 1536 times.
✓ Branch 4 taken 489 times.
✓ Branch 5 taken 1047 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 489 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1536 times.
15917 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
13848 {
13849
2/2
✓ Branch 0 taken 489 times.
✓ Branch 1 taken 1047 times.
1536 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
13850 1536 no_jinx = checkitem_jinx(attackid);
13851
3/8
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1536 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1536 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13852 {
13853
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1536 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
13854 paymagiccost(attackid,true);
13855 misc_internal_hero_flags |= LF_PAID_WAND_COST;
13856 }
13857 1536 SetAttack();
13858 1536 attack=wWand;
13859 1536 attackclk=0;
13860 1536 }
13861 else
13862 {
13863 item_error();
13864 }
13865 1536 }
13866
5/8
✓ Branch 0 taken 14381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 13616 times.
✓ Branch 4 taken 765 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 765 times.
15146 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
13867
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 765 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 763 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
765 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
13868 {
13869 765 no_jinx = checkitem_jinx(dowpn);
13870
3/6
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 765 times.
765 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
13871 {
13872 item_error();
13873 }
13874 else
13875 {
13876 765 paymagiccost(dowpn);
13877 765 paidmagic = true;
13878 765 SetAttack();
13879 765 attack=wHammer;
13880
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 763 times.
765 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
13881 765 attackclk=0;
13882 }
13883 765 }
13884
5/8
✓ Branch 0 taken 13616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165 times.
✓ Branch 3 taken 12451 times.
✓ Branch 4 taken 1165 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1165 times.
14781 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
13885
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1165 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 997 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
1165 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
13886 {
13887 //checkbunny handled where magic cost is paid
13888
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 168 times.
1165 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
13889 1165 no_jinx = checkitem_jinx(attackid);
13890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1165 times.
1165 if(no_jinx)
13891 {
13892 1165 SetAttack();
13893 1165 attack=wFire;
13894 1165 attackclk=0;
13895 1165 }
13896 1165 }
13897
5/8
✓ Branch 0 taken 12451 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 12447 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
12455 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
13898
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
13899 {
13900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
13901 4 no_jinx = checkitem_jinx(attackid);
13902
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13903 {
13904
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
13905 paymagiccost(attackid,true);
13906 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
13907 }
13908 4 SetAttack();
13909 4 attack=wCByrna;
13910 4 attackclk=0;
13911 4 }
13912 else
13913 {
13914 item_error();
13915 }
13916 4 }
13917
2/8
✓ Branch 0 taken 12447 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12447 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12447 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
13918 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
13919 {
13920 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
13921 no_jinx = checkitem_jinx(attackid);
13922 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
13923 {
13924 paymagiccost(attackid);
13925 SetAttack();
13926 attack = wBugNet;
13927 attackclk = 0;
13928 sfx(itemsbuf[attackid].usesound);
13929 }
13930 else
13931 {
13932 item_error();
13933 }
13934 }
13935 else
13936 {
13937
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 12370 times.
12447 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
13938 12447 no_jinx = checkitem_jinx(itmid);
13939
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 12433 times.
12447 if(no_jinx)
13940 {
13941 12433 paidmagic = startwpn(itmid);
13942
13943
2/2
✓ Branch 0 taken 10419 times.
✓ Branch 1 taken 2014 times.
12433 if(paidmagic)
13944 {
13945
5/10
✓ Branch 0 taken 10419 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10419 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10419 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10419 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 10419 times.
10419 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
13946 {
13947 ;
13948 }
13949 else
13950 {
13951 10419 SetAttack();
13952 10419 attackclk=0;
13953 10419 attack=none;
13954
13955
2/2
✓ Branch 0 taken 1746 times.
✓ Branch 1 taken 8673 times.
10419 if(btnwpn==itype_brang)
13956 {
13957 8673 attack=wBrang;
13958 8673 }
13959 }
13960 10419 }
13961 else
13962 {
13963 // Weapon not started: directWpn should be reset to prev. value.
13964 2014 directWpn = olddirectwpn;
13965 }
13966 12433 }
13967 }
13968
13969
8/12
✓ Branch 0 taken 15917 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15903 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 866 times.
✓ Branch 5 taken 15037 times.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
15917 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13970 {
13971
3/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 800 times.
800 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
13972 {
13973 item_error();
13974 }
13975 else
13976 {
13977 // Only charge for magic if item's magic cost wasn't already charged
13978 // for the item's main use.
13979
4/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 795 times.
800 if(!paidmagic && attack!=wWand)
13980 795 paymagiccost(dowpn);
13981 //clear the item script stack for a new script
13982 800 int i = dowpn;
13983 800 FFCore.reset_script_engine_data(ScriptType::Item, i);
13984 800 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13985 800 did_scriptb=true;
13986 }
13987 800 }
13988
13989
7/12
✓ Branch 0 taken 15903 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 15903 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15903 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15903 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15903 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 15903 times.
15917 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
13990 {
13991 return;
13992 }
13993
2/2
✓ Branch 0 taken 15903 times.
✓ Branch 1 taken 14 times.
15917 if(!no_jinx)
13994 14 did_scriptb = false;
13995 15917 }
13996 else
13997 {
13998 6100579 did_scriptb=false;
13999 }
14000
14001
5/6
✓ Branch 0 taken 5353282 times.
✓ Branch 1 taken 763214 times.
✓ Branch 2 taken 5292799 times.
✓ Branch 3 taken 60483 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5292799 times.
6116496 if(attackclk || action==attacking || action==sideswimattacking)
14002 {
14003
14004
4/8
✓ Branch 0 taken 60483 times.
✓ Branch 1 taken 763214 times.
✓ Branch 2 taken 60483 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60483 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
823697 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
14005 {
14006 if((xoff==0)||diagonalMovement)
14007 {
14008 if(DrunkUp()) dir=up;
14009 if(DrunkDown()) dir=down;
14010 }
14011
14012 if((yoff==0)||diagonalMovement)
14013 {
14014 if(DrunkLeft()) dir=left;
14015 if(DrunkRight()) dir=right;
14016 }
14017 }
14018
14019 823697 bool attacked = doattack();
14020
14021 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
14022
10/12
✓ Branch 0 taken 821904 times.
✓ Branch 1 taken 1793 times.
✓ Branch 2 taken 582366 times.
✓ Branch 3 taken 239538 times.
✓ Branch 4 taken 111768 times.
✓ Branch 5 taken 470598 times.
✓ Branch 6 taken 110092 times.
✓ Branch 7 taken 1676 times.
✓ Branch 8 taken 110092 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 110092 times.
823697 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
14023 {
14024
4/4
✓ Branch 0 taken 47006 times.
✓ Branch 1 taken 63086 times.
✓ Branch 2 taken 4695 times.
✓ Branch 3 taken 42311 times.
110092 if((xoff==0)||diagonalMovement)
14025 {
14026
2/2
✓ Branch 0 taken 60808 times.
✓ Branch 1 taken 6973 times.
67781 if(DrunkUp()) dir=up;
14027
14028
2/2
✓ Branch 0 taken 60518 times.
✓ Branch 1 taken 7263 times.
67781 if(DrunkDown()) dir=down;
14029 67781 }
14030
14031
4/4
✓ Branch 0 taken 35391 times.
✓ Branch 1 taken 74701 times.
✓ Branch 2 taken 3273 times.
✓ Branch 3 taken 32118 times.
110092 if((yoff==0)||diagonalMovement)
14032 {
14033
2/2
✓ Branch 0 taken 68685 times.
✓ Branch 1 taken 9289 times.
77974 if(DrunkLeft()) dir=left;
14034
14035
2/2
✓ Branch 0 taken 68901 times.
✓ Branch 1 taken 9073 times.
77974 if(DrunkRight()) dir=right;
14036 77974 }
14037 110092 }
14038
14039
9/10
✓ Branch 0 taken 765975 times.
✓ Branch 1 taken 57722 times.
✓ Branch 2 taken 764054 times.
✓ Branch 3 taken 1921 times.
✓ Branch 4 taken 763619 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 759404 times.
✓ Branch 7 taken 4215 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 759404 times.
823697 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
14040 {
14041 759404 return;
14042 }
14043
2/2
✓ Branch 0 taken 6571 times.
✓ Branch 1 taken 57722 times.
64293 else if(!attacked)
14044 {
14045 // Spin attack - change direction
14046
3/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 57474 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
57722 if(spins>1 && attack != wHammer)
14047 {
14048 248 spins--;
14049
14050
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 45 times.
248 if(spins%5==0)
14051 {
14052
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
14053 45 sfx(itemsbuf[id].usesound,pan(x.getInt()));
14054 45 }
14055 248 attackclk=1;
14056
14057
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
248 switch(dir)
14058 {
14059 case up:
14060 62 dir=left;
14061 62 break;
14062
14063 case right:
14064 62 dir=up;
14065 62 break;
14066
14067 case down:
14068 62 dir=right;
14069 62 break;
14070
14071 case left:
14072 62 dir=down;
14073 62 break;
14074 }
14075
14076 248 return;
14077 }
14078 else
14079 {
14080 57474 spins=0;
14081 }
14082
14083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57474 times.
57474 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
14084 57474 else {action=none; FFCore.setHeroAction(none);}
14085 57474 attackclk=0;
14086 57474 charging=0;
14087 57474 }
14088 64045 }
14089
14090
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 5356837 times.
5356844 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
14091 7 return;
14092
14093
2/2
✓ Branch 0 taken 2203932 times.
✓ Branch 1 taken 3152905 times.
5356837 if(action==walking) //still walking
14094 {
14095
9/10
✓ Branch 0 taken 2380986 times.
✓ Branch 1 taken 771919 times.
✓ Branch 2 taken 1753297 times.
✓ Branch 3 taken 627689 times.
✓ Branch 4 taken 934643 times.
✓ Branch 5 taken 818654 times.
✓ Branch 6 taken 41010 times.
✓ Branch 7 taken 893633 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 41010 times.
3152905 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
14096 {
14097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41010 times.
41010 if(attackclk>0) SetAttack();
14098 41010 else {action = none; FFCore.setHeroAction(none);}
14099 41010 hero_count=-1;
14100 41010 return;
14101 }
14102
14103 3111895 autostep=false;
14104
14105
4/6
✓ Branch 0 taken 2811474 times.
✓ Branch 1 taken 300421 times.
✓ Branch 2 taken 2811474 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2811474 times.
3111895 if(!(diagonalMovement || NO_GRIDLOCK))
14106 {
14107
2/4
✓ Branch 0 taken 2811474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2811474 times.
2811474 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
14108 {
14109 if(dir==up&&yoff)
14110 {
14111 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
14112 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
14113 execute(info);
14114
14115 if(!info.isUnwalkable())
14116 {
14117 moveOld2(up);
14118 }
14119 else
14120 {
14121 action=none; FFCore.setHeroAction(none);
14122 }
14123
14124 return;
14125 }
14126
14127 if(dir==down&&yoff)
14128 {
14129 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
14130 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
14131 execute(info);
14132
14133 if(!info.isUnwalkable())
14134 {
14135 moveOld2(down);
14136 }
14137 else
14138 {
14139 action=none; FFCore.setHeroAction(none);
14140 }
14141
14142 return;
14143 }
14144
14145 if(dir==left&&xoff)
14146 {
14147 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
14148 execute(info);
14149
14150 if(!info.isUnwalkable())
14151 {
14152 moveOld2(left);
14153 }
14154 else
14155 {
14156 action=none; FFCore.setHeroAction(none);
14157 }
14158
14159 return;
14160 }
14161
14162 if(dir==right&&xoff)
14163 {
14164 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
14165 execute(info);
14166
14167 if(!info.isUnwalkable())
14168 {
14169 moveOld2(right);
14170 }
14171 else
14172 {
14173 action=none; FFCore.setHeroAction(none);
14174 }
14175
14176 return;
14177 }
14178 }
14179 else
14180 {
14181
4/4
✓ Branch 0 taken 651512 times.
✓ Branch 1 taken 2159962 times.
✓ Branch 2 taken 107109 times.
✓ Branch 3 taken 544403 times.
2811474 if(dir==up&&yoff)
14182 {
14183 544403 while(true)
14184 {
14185 544403 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
14186 544403 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
14187 544403 execute(info);
14188
14189
2/2
✓ Branch 0 taken 2253 times.
✓ Branch 1 taken 542150 times.
544403 if(!info.isUnwalkable())
14190 {
14191 542150 hero_newstep = temp_step;
14192 542150 x = temp_x;
14193 542150 y = temp_y;
14194 542150 moveOld2(up);
14195 542150 return;
14196 }
14197 //Could not move, try moving less
14198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2253 times.
2253 if(temp_y != int32_t(temp_y))
14199 {
14200 temp_y = floor((double)temp_y);
14201 continue;
14202 }
14203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2253 times.
2253 else if(temp_step > 1)
14204 {
14205 if(temp_step != int32_t(temp_step)) //floor
14206 temp_step = floor((double)temp_step);
14207 else --temp_step;
14208 continue;
14209 }
14210 else //Can't move less, stop moving
14211 {
14212 2253 action=none; FFCore.setHeroAction(none);
14213 }
14214 2253 return;
14215 }
14216 }
14217
14218
4/4
✓ Branch 0 taken 532460 times.
✓ Branch 1 taken 1734611 times.
✓ Branch 2 taken 88196 times.
✓ Branch 3 taken 444264 times.
2267071 if(dir==down&&yoff)
14219 {
14220 444264 while(true)
14221 {
14222 444270 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
14223 444270 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
14224 444270 execute(info);
14225
14226
2/2
✓ Branch 0 taken 1862 times.
✓ Branch 1 taken 442408 times.
444270 if(!info.isUnwalkable())
14227 {
14228 442408 hero_newstep = temp_step;
14229 442408 x = temp_x;
14230 442408 y = temp_y;
14231 442408 moveOld2(down);
14232 442408 return;
14233 }
14234 //Could not move, try moving less
14235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(temp_y != int32_t(temp_y))
14236 {
14237 temp_y = floor((double)temp_y);
14238 continue;
14239 }
14240
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1856 times.
1862 else if(temp_step > 1)
14241 {
14242
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(temp_step != int32_t(temp_step)) //floor
14243 6 temp_step = floor((double)temp_step);
14244 else --temp_step;
14245 6 continue;
14246 }
14247 else //Can't move less, stop moving
14248 {
14249 1856 action=none; FFCore.setHeroAction(none);
14250 }
14251 1856 return;
14252 }
14253 }
14254
14255
4/4
✓ Branch 0 taken 784904 times.
✓ Branch 1 taken 1037903 times.
✓ Branch 2 taken 131797 times.
✓ Branch 3 taken 653107 times.
1822807 if(dir==left&&xoff)
14256 {
14257 653107 while(true)
14258 {
14259 653107 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
14260 653107 execute(info);
14261
14262
2/2
✓ Branch 0 taken 2018 times.
✓ Branch 1 taken 651089 times.
653107 if(!info.isUnwalkable())
14263 {
14264 651089 hero_newstep = temp_step;
14265 651089 x = temp_x;
14266 651089 y = temp_y;
14267 651089 moveOld2(left);
14268 651089 return;
14269 }
14270 //Could not move, try moving less
14271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2018 times.
2018 if(temp_x != int32_t(temp_x))
14272 {
14273 temp_x = floor((double)temp_x);
14274 continue;
14275 }
14276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2018 times.
2018 else if(temp_step > 1)
14277 {
14278 if(temp_step != int32_t(temp_step)) //floor
14279 temp_step = floor((double)temp_step);
14280 else --temp_step;
14281 continue;
14282 }
14283 else //Can't move less, stop moving
14284 {
14285 2018 action=none; FFCore.setHeroAction(none);
14286 }
14287 2018 return;
14288 }
14289 }
14290
14291
4/4
✓ Branch 0 taken 842598 times.
✓ Branch 1 taken 327102 times.
✓ Branch 2 taken 141165 times.
✓ Branch 3 taken 701433 times.
1169700 if(dir==right&&xoff)
14292 {
14293 701433 while(true)
14294 {
14295 701441 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
14296 701441 execute(info);
14297
14298
2/2
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 699434 times.
701441 if(!info.isUnwalkable())
14299 {
14300 699434 hero_newstep = temp_step;
14301 699434 x = temp_x;
14302 699434 y = temp_y;
14303 699434 moveOld2(right);
14304 699434 return;
14305 }
14306 //Could not move, try moving less
14307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2007 times.
2007 if(temp_x != int32_t(temp_x))
14308 {
14309 temp_x = floor((double)temp_x);
14310 continue;
14311 }
14312
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1999 times.
2007 else if(temp_step > 1)
14313 {
14314
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(temp_step != int32_t(temp_step)) //floor
14315 8 temp_step = floor((double)temp_step);
14316 else --temp_step;
14317 8 continue;
14318 }
14319 else //Can't move less, stop moving
14320 {
14321 1999 action=none; FFCore.setHeroAction(none);
14322 }
14323 1999 return;
14324 }
14325 }
14326 }
14327 468267 }
14328
14329 768688 } // endif (action==walking)
14330
14331
16/24
✓ Branch 0 taken 2908418 times.
✓ Branch 1 taken 64202 times.
✓ Branch 2 taken 2908418 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2908418 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2908418 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2908418 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2908418 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2908418 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2908418 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2908418 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2906497 times.
✓ Branch 19 taken 1921 times.
✓ Branch 20 taken 2906062 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 74717 times.
✓ Branch 23 taken 2831345 times.
2972620 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
14332 {
14333 2831345 action=none; FFCore.setHeroAction(none);
14334 2831345 }
14335
14336
2/2
✓ Branch 0 taken 643021 times.
✓ Branch 1 taken 2329599 times.
2972620 if(diagonalMovement)
14337 {
14338
5/5
✓ Branch 0 taken 243536 times.
✓ Branch 1 taken 60243 times.
✓ Branch 2 taken 45333 times.
✓ Branch 3 taken 134702 times.
✓ Branch 4 taken 159207 times.
643021 switch(holddir)
14339 {
14340 case up:
14341
2/2
✓ Branch 0 taken 58256 times.
✓ Branch 1 taken 1987 times.
60243 if(!Up())
14342 {
14343 1987 holddir=-1;
14344 1987 }
14345
14346 60243 break;
14347
14348 case down:
14349
2/2
✓ Branch 0 taken 43529 times.
✓ Branch 1 taken 1804 times.
45333 if(!Down())
14350 {
14351 1804 holddir=-1;
14352 1804 }
14353
14354 45333 break;
14355
14356 case left:
14357
2/2
✓ Branch 0 taken 130611 times.
✓ Branch 1 taken 4091 times.
134702 if(!Left())
14358 {
14359 4091 holddir=-1;
14360 4091 }
14361
14362 134702 break;
14363
14364 case right:
14365
2/2
✓ Branch 0 taken 154690 times.
✓ Branch 1 taken 4517 times.
159207 if(!Right())
14366 {
14367 4517 holddir=-1;
14368 4517 }
14369
14370 159207 break;
14371
14372 default:
14373 243536 break;
14374 } //end switch
14375
14376
3/4
✓ Branch 0 taken 513820 times.
✓ Branch 1 taken 129201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 513820 times.
643021 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
14377 {
14378 129201 walkable = false;
14379
6/6
✓ Branch 0 taken 23269 times.
✓ Branch 1 taken 105932 times.
✓ Branch 2 taken 22526 times.
✓ Branch 3 taken 743 times.
✓ Branch 4 taken 5947 times.
✓ Branch 5 taken 16579 times.
129201 if(DrunkUp()&&(holddir==-1||holddir==up))
14380 {
14381
4/8
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 17236 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 86 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17322 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14382 {
14383 }
14384 else
14385 {
14386
4/10
✓ Branch 0 taken 17322 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17322 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17322 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 17322 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
17322 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14387 {
14388 17322 dir=up;
14389 17322 }
14390
14391 17322 holddir=up;
14392
14393
3/4
✓ Branch 0 taken 1981 times.
✓ Branch 1 taken 15341 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1981 times.
17322 if(DrunkRight()&&shiftdir!=left)
14394 {
14395 1981 shiftdir=right;
14396
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1981 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1981 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14397
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1981 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1981 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14398 1981 }
14399
4/4
✓ Branch 0 taken 2163 times.
✓ Branch 1 taken 13178 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2161 times.
15341 else if(DrunkLeft()&&shiftdir!=right)
14400 {
14401 2161 shiftdir=left;
14402
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2161 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14403
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2161 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14404 2161 }
14405 else
14406 {
14407 13180 shiftdir=-1;
14408 }
14409
14410 //walkable if Ladder can be placed or is already placed vertically
14411
1/20
✗ Branch 0 not taken.
✓ Branch 1 taken 17322 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
17322 if(isSideViewHero() && !toogam && (!get_bit(quest_rules, qr_OLD_LADDER_ITEM_SIDEVIEW) || !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up))) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14412 {
14413 walkable=false;
14414 }
14415 else
14416 {
14417 17322 do
14418 {
14419 19884 zfix ty = y - hero_newstep;
14420 39768 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14421 19884 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14422
14423
3/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 19836 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
19884 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14424 {
14425 48 info = info || walkflag(x, zfix(0), 2, up);
14426 48 info = info || walkflag(x+15, zfix(0), 1, up);
14427 48 }
14428 19884 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
14429
14430 19884 execute(info);
14431
14432
2/2
✓ Branch 0 taken 4929 times.
✓ Branch 1 taken 14955 times.
19884 if(info.isUnwalkable())
14433 {
14434
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 4734 times.
4929 if(y != y.getInt())
14435 {
14436 195 y.doRound();
14437 195 }
14438
2/2
✓ Branch 0 taken 2367 times.
✓ Branch 1 taken 2367 times.
4734 else if(hero_newstep > 1)
14439 {
14440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2367 times.
2367 if(hero_newstep != int32_t(hero_newstep)) //floor
14441 2367 hero_newstep = floor((double)hero_newstep);
14442 else --hero_newstep;
14443 2367 }
14444 else
14445 2367 break;
14446 2562 }
14447 14955 else walkable = true;
14448
2/2
✓ Branch 0 taken 2562 times.
✓ Branch 1 taken 14955 times.
17517 }
14449 17517 while(!walkable);
14450 }
14451
14452 17322 int32_t s=shiftdir;
14453
14454
4/6
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 17236 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86 times.
✗ Branch 5 not taken.
17322 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14455 {
14456 shiftdir=-1;
14457 }
14458 else
14459 {
14460
2/2
✓ Branch 0 taken 2161 times.
✓ Branch 1 taken 15161 times.
17322 if(s==left)
14461 {
14462 2161 do
14463 {
14464 2559 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14465
14466 2559 execute(info);
14467
14468
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 1799 times.
2559 if(info.isUnwalkable())
14469 {
14470
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 724 times.
760 if(x != x.getInt())
14471 {
14472 36 x.doRound();
14473 36 }
14474
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 362 times.
724 else if(hero_newstep_diag > 1)
14475 {
14476
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14477 362 hero_newstep_diag.doFloor();
14478 else --hero_newstep_diag;
14479 362 }
14480 else
14481 362 shiftdir = -1;
14482 760 }
14483
2/2
✓ Branch 0 taken 1569 times.
✓ Branch 1 taken 230 times.
1799 else if(walkable)
14484 {
14485 1569 do
14486 {
14487 1572 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
14488 1572 execute(info);
14489
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1567 times.
1572 if(info.isUnwalkable())
14490 {
14491
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if(x != x.getInt())
14492 {
14493 1 x.doRound();
14494 1 }
14495
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
14496 {
14497
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14498 2 hero_newstep_diag.doFloor();
14499 else --hero_newstep_diag;
14500 2 }
14501 else
14502 2 shiftdir = -1;
14503 5 }
14504 1567 else break;
14505
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 }
14506 5 while(shiftdir != -1);
14507 1569 break;
14508 }
14509 230 else break;
14510
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 362 times.
760 }
14511 760 while(shiftdir != -1);
14512 2161 }
14513
2/2
✓ Branch 0 taken 13180 times.
✓ Branch 1 taken 1981 times.
15161 else if(s==right)
14514 {
14515 1981 do
14516 {
14517 2287 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14518
14519 2287 execute(info);
14520
14521
2/2
✓ Branch 0 taken 577 times.
✓ Branch 1 taken 1710 times.
2287 if(info.isUnwalkable())
14522 {
14523
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 542 times.
577 if(x != x.getInt())
14524 {
14525 35 x.doRound();
14526 35 }
14527
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 271 times.
542 else if(hero_newstep_diag > 1)
14528 {
14529
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14530 271 hero_newstep_diag.doFloor();
14531 else --hero_newstep_diag;
14532 271 }
14533 else
14534 271 shiftdir = -1;
14535 577 }
14536
2/2
✓ Branch 0 taken 1483 times.
✓ Branch 1 taken 227 times.
1710 else if(walkable)
14537 {
14538 1483 do
14539 {
14540 1489 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
14541 1489 execute(info);
14542
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1478 times.
1489 if(info.isUnwalkable())
14543 {
14544
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14545 {
14546 1 x.doRound();
14547 1 }
14548
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14549 {
14550
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14551 5 hero_newstep_diag.doFloor();
14552 else --hero_newstep_diag;
14553 5 }
14554 else
14555 5 shiftdir = -1;
14556 11 }
14557 1478 else break;
14558
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14559 11 while(shiftdir != -1);
14560 1483 break;
14561 }
14562 227 else break;
14563
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 271 times.
577 }
14564 577 while(shiftdir != -1);
14565 1981 }
14566 }
14567
14568 17322 moveOld2(up);
14569 17322 shiftdir=s;
14570
14571
2/2
✓ Branch 0 taken 14955 times.
✓ Branch 1 taken 2367 times.
17322 if(!walkable)
14572 {
14573
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 1839 times.
2367 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14574 {
14575 1839 x = x.getInt();
14576 1839 y = y.getInt();
14577
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1839 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1839 times.
✓ Branch 4 taken 1555 times.
✓ Branch 5 taken 284 times.
✓ Branch 6 taken 116 times.
✓ Branch 7 taken 1723 times.
2123 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14578
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 284 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 284 times.
✓ Branch 4 taken 161 times.
✓ Branch 5 taken 123 times.
284 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14579
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
123 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14580 {
14581
5/8
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 116 times.
116 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
14582 116 sprite::move((zfix)-1,(zfix)0);
14583 116 }
14584 else
14585 {
14586
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1723 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1723 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 1555 times.
✓ Branch 6 taken 126 times.
✓ Branch 7 taken 1597 times.
3278 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14587
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1555 times.
✓ Branch 2 taken 1555 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1429 times.
✓ Branch 5 taken 126 times.
1555 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14588
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14589 {
14590
4/8
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 126 times.
126 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
14591 126 sprite::move((zfix)1,(zfix)0);
14592 126 }
14593 else
14594 {
14595 1597 pushing=push+1;
14596 }
14597 }
14598 1839 }
14599 else
14600 {
14601 528 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14602 }
14603 2367 }
14604
14605 17322 return;
14606 }
14607 }
14608
14609
6/6
✓ Branch 0 taken 22210 times.
✓ Branch 1 taken 89669 times.
✓ Branch 2 taken 21390 times.
✓ Branch 3 taken 820 times.
✓ Branch 4 taken 16021 times.
✓ Branch 5 taken 5369 times.
111879 if(DrunkDown()&&(holddir==-1||holddir==down))
14610 {
14611
4/8
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 16708 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16841 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14612 {
14613 }
14614 else
14615 {
14616
4/10
✓ Branch 0 taken 16841 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16841 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16841 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16841 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
16841 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14617 {
14618 16841 dir=down;
14619 16841 }
14620
14621 16841 holddir=down;
14622
14623
4/4
✓ Branch 0 taken 2469 times.
✓ Branch 1 taken 14372 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2467 times.
16841 if(DrunkRight()&&shiftdir!=left)
14624 {
14625 2467 shiftdir=right;
14626
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2467 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14627
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2467 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14628 2467 }
14629
4/4
✓ Branch 0 taken 2502 times.
✓ Branch 1 taken 11872 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2501 times.
14374 else if(DrunkLeft()&&shiftdir!=right)
14630 {
14631 2501 shiftdir=left;
14632
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2501 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14633
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2501 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14634 2501 }
14635 else
14636 {
14637 11873 shiftdir=-1;
14638 }
14639
14640 //bool walkable;
14641
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 16841 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
16841 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14642 {
14643 walkable=false;
14644 }
14645 else
14646 {
14647 16841 do
14648 {
14649 18742 info = walkflag(x,15+(y+hero_newstep),2,down);
14650
14651
2/2
✓ Branch 0 taken 10919 times.
✓ Branch 1 taken 7823 times.
18742 if(x.getFloor() & 7)
14652 10919 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
14653 else
14654 7823 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
14655
14656 18742 execute(info);
14657
14658
2/2
✓ Branch 0 taken 3574 times.
✓ Branch 1 taken 15168 times.
18742 if(info.isUnwalkable())
14659 {
14660
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 3358 times.
3574 if(y != y.getInt())
14661 {
14662 216 y.doRound();
14663 216 }
14664
2/2
✓ Branch 0 taken 1685 times.
✓ Branch 1 taken 1673 times.
3358 else if(hero_newstep > 1)
14665 {
14666
1/2
✓ Branch 0 taken 1685 times.
✗ Branch 1 not taken.
1685 if(hero_newstep != int32_t(hero_newstep)) //floor
14667 1685 hero_newstep = floor((double)hero_newstep);
14668 else --hero_newstep;
14669 1685 }
14670 else
14671 1673 break;
14672 1901 }
14673 15168 else walkable = true;
14674
2/2
✓ Branch 0 taken 1901 times.
✓ Branch 1 taken 15168 times.
17069 }
14675 17069 while(!walkable);
14676 }
14677
14678 16841 int32_t s=shiftdir;
14679
14680
4/6
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 16708 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
16841 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14681 {
14682 shiftdir=-1;
14683 }
14684 else
14685 {
14686
2/2
✓ Branch 0 taken 2501 times.
✓ Branch 1 taken 14340 times.
16841 if(s==left)
14687 {
14688 2501 do
14689 {
14690 2886 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14691
14692 2886 execute(info);
14693
14694
2/2
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 2168 times.
2886 if(info.isUnwalkable())
14695 {
14696
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 666 times.
718 if(x != x.getInt())
14697 {
14698 52 x.doRound();
14699 52 }
14700
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 333 times.
666 else if(hero_newstep_diag > 1)
14701 {
14702
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14703 333 hero_newstep_diag.doFloor();
14704 else --hero_newstep_diag;
14705 333 }
14706 else
14707 333 shiftdir = -1;
14708 718 }
14709
2/2
✓ Branch 0 taken 1926 times.
✓ Branch 1 taken 242 times.
2168 else if(walkable)
14710 {
14711 1926 do
14712 {
14713 1933 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
14714 1933 execute(info);
14715
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1923 times.
1933 if(info.isUnwalkable())
14716 {
14717
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if(x != x.getInt())
14718 {
14719 4 x.doRound();
14720 4 }
14721
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14722 {
14723
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14724 3 hero_newstep_diag.doFloor();
14725 else --hero_newstep_diag;
14726 3 }
14727 else
14728 3 shiftdir = -1;
14729 10 }
14730 1923 else break;
14731
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 }
14732 10 while(shiftdir != -1);
14733 1926 break;
14734 }
14735 242 else break;
14736
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 333 times.
718 }
14737 718 while(shiftdir != -1);
14738 2501 }
14739
2/2
✓ Branch 0 taken 11873 times.
✓ Branch 1 taken 2467 times.
14340 else if(s==right)
14740 {
14741 2467 do
14742 {
14743 2793 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14744
14745 2793 execute(info);
14746
14747
2/2
✓ Branch 0 taken 628 times.
✓ Branch 1 taken 2165 times.
2793 if(info.isUnwalkable())
14748 {
14749
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 604 times.
628 if(x != x.getInt())
14750 {
14751 24 x.doRound();
14752 24 }
14753
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 302 times.
604 else if(hero_newstep_diag > 1)
14754 {
14755
1/2
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
302 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14756 302 hero_newstep_diag.doFloor();
14757 else --hero_newstep_diag;
14758 302 }
14759 else
14760 302 shiftdir = -1;
14761 628 }
14762
2/2
✓ Branch 0 taken 1914 times.
✓ Branch 1 taken 251 times.
2165 else if(walkable)
14763 {
14764 1914 do
14765 {
14766 1918 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
14767 1918 execute(info);
14768
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1910 times.
1918 if(info.isUnwalkable())
14769 {
14770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(x != x.getInt())
14771 {
14772 x.doRound();
14773 }
14774
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 else if(hero_newstep_diag > 1)
14775 {
14776
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14777 4 hero_newstep_diag.doFloor();
14778 else --hero_newstep_diag;
14779 4 }
14780 else
14781 4 shiftdir = -1;
14782 8 }
14783 1910 else break;
14784
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 }
14785 8 while(shiftdir != -1);
14786 1914 break;
14787 }
14788 251 else break;
14789
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 302 times.
628 }
14790 628 while(shiftdir != -1);
14791 2467 }
14792 }
14793
14794 16841 moveOld2(down);
14795 16841 shiftdir=s;
14796
14797
2/2
✓ Branch 0 taken 15168 times.
✓ Branch 1 taken 1673 times.
16841 if(!walkable)
14798 {
14799
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 1150 times.
1673 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14800 {
14801 1150 x = x.getInt();
14802 1150 y = y.getInt();
14803
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1150 times.
✓ Branch 2 taken 1150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 914 times.
✓ Branch 5 taken 236 times.
✓ Branch 6 taken 134 times.
✓ Branch 7 taken 1016 times.
1386 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14804
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
✓ Branch 2 taken 236 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✓ Branch 5 taken 134 times.
236 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
14805
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 134 times.
✓ Branch 2 taken 134 times.
✗ Branch 3 not taken.
134 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14806 {
14807
4/8
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 134 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 134 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 134 times.
134 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
14808 134 sprite::move((zfix)-1,(zfix)0);
14809 134 }
14810
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1016 times.
✓ Branch 2 taken 1016 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✓ Branch 5 taken 914 times.
✓ Branch 6 taken 146 times.
✓ Branch 7 taken 870 times.
1930 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14811
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 914 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 768 times.
✓ Branch 5 taken 146 times.
914 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
14812
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 146 times.
146 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14813 {
14814
4/8
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 146 times.
146 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
14815 146 sprite::move((zfix)1,(zfix)0);
14816 146 }
14817 else
14818 {
14819 870 pushing=push+1;
14820 }
14821 1150 }
14822 else
14823 {
14824 523 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14825 }
14826 1673 }
14827
14828 16841 return;
14829 }
14830 }
14831
14832
6/6
✓ Branch 0 taken 23451 times.
✓ Branch 1 taken 71587 times.
✓ Branch 2 taken 22584 times.
✓ Branch 3 taken 867 times.
✓ Branch 4 taken 22576 times.
✓ Branch 5 taken 8 times.
95038 if(DrunkLeft()&&(holddir==-1||holddir==left))
14833 {
14834
4/8
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 23386 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
23443 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14835 {
14836 }
14837 else
14838 {
14839
3/6
✓ Branch 0 taken 23443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23443 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23443 times.
23443 if(charging==0 && spins==0 && action != sideswimattacking)
14840 {
14841 23443 dir=left;
14842 23443 }
14843 23443 sideswimdir = left;
14844
14845 23443 holddir=left;
14846
14847
3/4
✓ Branch 0 taken 3157 times.
✓ Branch 1 taken 20286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3157 times.
23443 if(DrunkUp()&&shiftdir!=down)
14848 {
14849 3157 shiftdir=up;
14850 3157 }
14851
3/4
✓ Branch 0 taken 2582 times.
✓ Branch 1 taken 17704 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2582 times.
20286 else if(DrunkDown()&&shiftdir!=up)
14852 {
14853 2582 shiftdir=down;
14854 2582 }
14855 else
14856 {
14857 17704 shiftdir=-1;
14858 }
14859
14860 23443 do
14861 {
14862 26092 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
14863
14864 26092 info = info || walkflag(x-hero_newstep,y+15,1,left);
14865
14866 26092 execute(info);
14867
14868
2/2
✓ Branch 0 taken 5085 times.
✓ Branch 1 taken 21007 times.
26092 if(info.isUnwalkable())
14869 {
14870
2/2
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 4872 times.
5085 if(x != x.getInt())
14871 {
14872 213 x.doRound();
14873 213 }
14874
2/2
✓ Branch 0 taken 2436 times.
✓ Branch 1 taken 2436 times.
4872 else if(hero_newstep > 1)
14875 {
14876
1/2
✓ Branch 0 taken 2436 times.
✗ Branch 1 not taken.
2436 if(hero_newstep != int32_t(hero_newstep)) //floor
14877 2436 hero_newstep = floor((double)hero_newstep);
14878 else --hero_newstep;
14879 2436 }
14880 else
14881 2436 break;
14882 2649 }
14883 21007 else walkable = true;
14884
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 21007 times.
23656 }
14885 23656 while(!walkable);
14886
14887 23443 int32_t s=shiftdir;
14888
14889
5/14
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 23386 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 23443 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
23443 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14890 {
14891 shiftdir=-1;
14892 }
14893 else
14894 {
14895
2/2
✓ Branch 0 taken 20286 times.
✓ Branch 1 taken 3157 times.
23443 if(s==up)
14896 {
14897 3157 do
14898 {
14899 3627 zfix ty = y - hero_newstep_diag;
14900 7254 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14901 3627 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14902
14903
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3626 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
3627 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14904 {
14905 1 info = info || walkflag(x, zfix(0), 2, up);
14906 1 info = info || walkflag(x+15, zfix(0), 1, up);
14907 1 }
14908 3627 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
14909
14910 3627 execute(info);
14911
14912
2/2
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 2732 times.
3627 if(info.isUnwalkable())
14913 {
14914
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 850 times.
895 if(y != y.getInt())
14915 {
14916 45 y.doRound();
14917 45 }
14918
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 425 times.
850 else if(hero_newstep_diag > 1)
14919 {
14920
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14921 425 hero_newstep_diag.doFloor();
14922 else --hero_newstep_diag;
14923 425 }
14924 else
14925 425 shiftdir = -1;
14926 895 }
14927
2/2
✓ Branch 0 taken 2215 times.
✓ Branch 1 taken 517 times.
2732 else if(walkable)
14928 {
14929 2215 do
14930 {
14931 2237 zfix tx = x-hero_newstep, ty = y-hero_newstep_diag;
14932 2237 info = walkflag(tx,(bigHitbox?0:8)+ty,1,up);
14933
14934
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2236 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
2237 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14935 {
14936 1 info = info || walkflag(tx, zfix(0), 1, up);
14937 1 info = info || walkflag(tx+15, zfix(0), 1, up);
14938 1 }
14939 2237 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
14940
14941 2237 execute(info);
14942
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2202 times.
2237 if(info.isUnwalkable())
14943 {
14944
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26 times.
35 if(y != y.getInt())
14945 {
14946 9 y.doRound();
14947 9 }
14948
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 else if(hero_newstep_diag > 1)
14949 {
14950
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14951 13 hero_newstep_diag.doFloor();
14952 else --hero_newstep_diag;
14953 13 }
14954 else
14955 13 shiftdir = -1;
14956 35 }
14957 2202 else break;
14958
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13 times.
35 }
14959 35 while(shiftdir != -1);
14960 2215 break;
14961 }
14962 517 else break;
14963
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 425 times.
895 }
14964 895 while(shiftdir != -1);
14965 3157 }
14966
2/2
✓ Branch 0 taken 17704 times.
✓ Branch 1 taken 2582 times.
20286 else if(s==down)
14967 {
14968 2582 do
14969 {
14970 3018 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14971
14972 3018 execute(info);
14973
14974
2/2
✓ Branch 0 taken 825 times.
✓ Branch 1 taken 2193 times.
3018 if(info.isUnwalkable())
14975 {
14976
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 778 times.
825 if(y != y.getInt())
14977 {
14978 47 y.doRound();
14979 47 }
14980
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 389 times.
778 else if(hero_newstep_diag > 1)
14981 {
14982
1/2
✓ Branch 0 taken 389 times.
✗ Branch 1 not taken.
389 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14983 389 hero_newstep_diag.doFloor();
14984 else --hero_newstep_diag;
14985 389 }
14986 else
14987 389 shiftdir = -1;
14988 825 }
14989
2/2
✓ Branch 0 taken 1809 times.
✓ Branch 1 taken 384 times.
2193 else if(walkable)
14990 {
14991 1809 do
14992 {
14993 1812 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
14994 1812 execute(info);
14995
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1807 times.
1812 if(info.isUnwalkable())
14996 {
14997
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if(y != y.getInt())
14998 {
14999 1 y.doRound();
15000 1 }
15001
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
15002 {
15003
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15004 2 hero_newstep_diag.doFloor();
15005 else --hero_newstep_diag;
15006 2 }
15007 else
15008 2 shiftdir = -1;
15009 5 }
15010 1807 else break;
15011
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 }
15012 5 while(shiftdir != -1);
15013 1809 break;
15014 }
15015 384 else break;
15016
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 389 times.
825 }
15017 825 while(shiftdir != -1);
15018 2582 }
15019 }
15020
15021 23443 moveOld2(left);
15022 23443 shiftdir=s;
15023
15024
2/2
✓ Branch 0 taken 21007 times.
✓ Branch 1 taken 2436 times.
23443 if(!walkable)
15025 {
15026
2/2
✓ Branch 0 taken 973 times.
✓ Branch 1 taken 1463 times.
2436 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15027 {
15028 1463 x = x.getInt();
15029 1463 y = y.getInt();
15030 1463 int32_t v1=bigHitbox?0:8;
15031 1463 int32_t v2=bigHitbox?8:12;
15032
15033
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1463 times.
✓ Branch 2 taken 1463 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1275 times.
✓ Branch 5 taken 188 times.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 1432 times.
1651 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15034
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
✓ Branch 4 taken 157 times.
✓ Branch 5 taken 31 times.
188 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15035
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
31 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15036 {
15037
4/8
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31 times.
31 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15038 31 sprite::move((zfix)0,(zfix)-1);
15039 31 }
15040
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1432 times.
✓ Branch 4 taken 157 times.
✓ Branch 5 taken 1275 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1396 times.
2707 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15041
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1275 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1275 times.
✓ Branch 4 taken 1239 times.
✓ Branch 5 taken 36 times.
1275 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15042
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
36 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15043 {
15044
4/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 36 times.
36 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15045 36 sprite::move((zfix)0,(zfix)1);
15046 36 }
15047 else
15048 {
15049 1396 pushing=push+1;
15050 }
15051 1463 }
15052 else
15053 {
15054 973 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15055
15056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 973 times.
973 if(action!=swimming)
15057 {
15058 973 }
15059 }
15060 2436 }
15061
15062 23443 return;
15063 }
15064 }
15065
15066
5/6
✓ Branch 0 taken 25065 times.
✓ Branch 1 taken 46530 times.
✓ Branch 2 taken 24205 times.
✓ Branch 3 taken 860 times.
✓ Branch 4 taken 24205 times.
✗ Branch 5 not taken.
71595 if(DrunkRight()&&(holddir==-1||holddir==right))
15067 {
15068
4/8
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 24907 times.
✓ Branch 2 taken 158 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 158 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25065 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15069 {
15070 }
15071 else
15072 {
15073
3/6
✓ Branch 0 taken 25065 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25065 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25065 times.
25065 if(charging==0 && spins==0 && action != sideswimattacking)
15074 {
15075 25065 dir=right;
15076 25065 }
15077 25065 sideswimdir = right;
15078
15079 25065 holddir=right;
15080
15081
3/4
✓ Branch 0 taken 2788 times.
✓ Branch 1 taken 22277 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2788 times.
25065 if(DrunkUp()&&shiftdir!=down)
15082 {
15083 2788 shiftdir=up;
15084 2788 }
15085
4/4
✓ Branch 0 taken 2786 times.
✓ Branch 1 taken 19491 times.
✓ Branch 2 taken 2784 times.
✓ Branch 3 taken 2 times.
22277 else if(DrunkDown()&&shiftdir!=up)
15086 {
15087 2784 shiftdir=down;
15088 2784 }
15089 else
15090 {
15091 19493 shiftdir=-1;
15092 }
15093
15094 25065 do
15095 {
15096 27722 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
15097
15098 27722 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
15099
15100 27722 execute(info);
15101
15102
2/2
✓ Branch 0 taken 5090 times.
✓ Branch 1 taken 22632 times.
27722 if(info.isUnwalkable())
15103 {
15104
2/2
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 4877 times.
5090 if(x != x.getInt())
15105 {
15106 213 x.doRound();
15107 213 }
15108
2/2
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 2433 times.
4877 else if(hero_newstep > 1)
15109 {
15110
1/2
✓ Branch 0 taken 2444 times.
✗ Branch 1 not taken.
2444 if(hero_newstep != int32_t(hero_newstep)) //floor
15111 2444 hero_newstep = floor((double)hero_newstep);
15112 else --hero_newstep;
15113 2444 }
15114 else
15115 2433 break;
15116 2657 }
15117 22632 else walkable = true;
15118
2/2
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 22632 times.
25289 }
15119 25289 while(!walkable);
15120
15121 25065 int32_t s=shiftdir;
15122
15123
6/14
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 24907 times.
✓ Branch 2 taken 151 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 158 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 25065 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
25065 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15124 {
15125 shiftdir=-1;
15126 }
15127 else
15128 {
15129
2/2
✓ Branch 0 taken 22277 times.
✓ Branch 1 taken 2788 times.
25065 if(s==up)
15130 {
15131 2788 do
15132 {
15133 3072 zfix ty = y - hero_newstep_diag;
15134 6144 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15135 3072 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15136
15137
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3072 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3072 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15138 {
15139 info = info || walkflag(x, zfix(0), 2, up);
15140 info = info || walkflag(x+15, zfix(0), 1, up);
15141 }
15142 3072 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15143
15144 3072 execute(info);
15145
15146
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 2545 times.
3072 if(info.isUnwalkable())
15147 {
15148
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 486 times.
527 if(y != y.getInt())
15149 {
15150 41 y.doRound();
15151 41 }
15152
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 243 times.
486 else if(hero_newstep_diag > 1)
15153 {
15154
1/2
✓ Branch 0 taken 243 times.
✗ Branch 1 not taken.
243 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15155 243 hero_newstep_diag.doFloor();
15156 else --hero_newstep_diag;
15157 243 }
15158 else
15159 243 shiftdir = -1;
15160 527 }
15161
2/2
✓ Branch 0 taken 2210 times.
✓ Branch 1 taken 335 times.
2545 else if(walkable)
15162 {
15163 2210 do
15164 {
15165 2229 zfix tx = x+hero_newstep, ty = y-hero_newstep_diag;
15166 2229 info = walkflag(tx+15,(bigHitbox?0:8)+ty,1,up);
15167
15168
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2229 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2229 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15169 {
15170 info = info || walkflag(tx, zfix(0), 1, up);
15171 info = info || walkflag(tx+15, zfix(0), 1, up);
15172 }
15173 2229 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
15174 2229 execute(info);
15175
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2199 times.
2229 if(info.isUnwalkable())
15176 {
15177
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 22 times.
30 if(y != y.getInt())
15178 {
15179 8 y.doRound();
15180 8 }
15181
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(hero_newstep_diag > 1)
15182 {
15183
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15184 11 hero_newstep_diag.doFloor();
15185 else --hero_newstep_diag;
15186 11 }
15187 else
15188 11 shiftdir = -1;
15189 30 }
15190 2199 else break;
15191
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 11 times.
30 }
15192 30 while(shiftdir != -1);
15193 2210 break;
15194 }
15195 335 else break;
15196
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 243 times.
527 }
15197 527 while(shiftdir != -1);
15198 2788 }
15199
2/2
✓ Branch 0 taken 19493 times.
✓ Branch 1 taken 2784 times.
22277 else if(s==down)
15200 {
15201 2784 do
15202 {
15203 3281 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
15204
15205 3281 execute(info);
15206
15207
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 2348 times.
3281 if(info.isUnwalkable())
15208 {
15209
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 872 times.
933 if(y != y.getInt())
15210 {
15211 61 y.doRound();
15212 61 }
15213
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 436 times.
872 else if(hero_newstep_diag > 1)
15214 {
15215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15216 436 hero_newstep_diag.doFloor();
15217 else --hero_newstep_diag;
15218 436 }
15219 else
15220 436 shiftdir = -1;
15221 933 }
15222
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 360 times.
2348 else if(walkable)
15223 {
15224 1988 do
15225 {
15226 2000 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
15227 2000 execute(info);
15228
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1981 times.
2000 if(info.isUnwalkable())
15229 {
15230
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15 times.
19 if(y != y.getInt())
15231 {
15232 4 y.doRound();
15233 4 }
15234
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 7 times.
15 else if(hero_newstep_diag > 1)
15235 {
15236
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15237 8 hero_newstep_diag.doFloor();
15238 else --hero_newstep_diag;
15239 8 }
15240 else
15241 7 shiftdir = -1;
15242 19 }
15243 1981 else break;
15244
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 }
15245 19 while(shiftdir != -1);
15246 1988 break;
15247 }
15248 360 else break;
15249
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 436 times.
933 }
15250 933 while(shiftdir != -1);
15251 2784 }
15252 }
15253
15254 25065 moveOld2(right);
15255 25065 shiftdir=s;
15256
15257
2/2
✓ Branch 0 taken 22632 times.
✓ Branch 1 taken 2433 times.
25065 if(!walkable)
15258 {
15259
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 1683 times.
2433 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15260 {
15261 1683 x = x.getInt();
15262 1683 y = y.getInt();
15263 1683 int32_t v1=bigHitbox?0:8;
15264 1683 int32_t v2=bigHitbox?8:12;
15265
15266
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1683 times.
✓ Branch 2 taken 1683 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1547 times.
✓ Branch 5 taken 136 times.
✓ Branch 6 taken 47 times.
✓ Branch 7 taken 1636 times.
1819 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
15267
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 47 times.
136 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
15268
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
15269 {
15270
4/8
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 47 times.
47 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15271 47 sprite::move((zfix)0,(zfix)-1);
15272 47 }
15273
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
✓ Branch 2 taken 1636 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 1547 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 1579 times.
3183 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
15274
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
✓ Branch 4 taken 1490 times.
✓ Branch 5 taken 57 times.
1547 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
15275
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
57 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
15276 {
15277
4/8
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 57 times.
57 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15278 57 sprite::move((zfix)0,(zfix)1);
15279 57 }
15280 else
15281 {
15282 1579 pushing=push+1;
15283 1579 z3step=2;
15284 }
15285 1683 }
15286 else
15287 {
15288 750 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15289
15290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750 times.
750 if(action!=swimming)
15291 {
15292 750 }
15293 }
15294 2433 }
15295
15296 25065 return;
15297 }
15298 }
15299 46530 }
15300 else
15301 {
15302
6/6
✓ Branch 0 taken 55400 times.
✓ Branch 1 taken 458420 times.
✓ Branch 2 taken 54153 times.
✓ Branch 3 taken 1247 times.
✓ Branch 4 taken 12476 times.
✓ Branch 5 taken 41677 times.
513820 if(DrunkUp()&&(holddir==-1||holddir==up))
15303 {
15304
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42924 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42924 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15305 {
15306 }
15307 else
15308 {
15309
2/4
✓ Branch 0 taken 42924 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42924 times.
42924 if(charging==0 && spins==0)
15310 {
15311 42924 dir=up;
15312 42924 }
15313
15314 42924 holddir=up;
15315
15316
4/4
✓ Branch 0 taken 5386 times.
✓ Branch 1 taken 37538 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 5379 times.
42924 if(DrunkRight()&&shiftdir!=left)
15317 {
15318 5379 shiftdir=right;
15319 5379 }
15320
4/4
✓ Branch 0 taken 4022 times.
✓ Branch 1 taken 33523 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 4016 times.
37545 else if(DrunkLeft()&&shiftdir!=right)
15321 {
15322 4016 shiftdir=left;
15323 4016 }
15324 else
15325 {
15326 33529 shiftdir=-1;
15327 }
15328
15329 //walkable if Ladder can be placed or is already placed vertically
15330
10/18
✓ Branch 0 taken 16485 times.
✓ Branch 1 taken 26439 times.
✓ Branch 2 taken 16485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16354 times.
✓ Branch 5 taken 131 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16354 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 16354 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 16354 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16354 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16354 times.
42924 if(isSideViewHero() && !toogam && !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15331 {
15332 16354 walkable=false;
15333 16354 }
15334 else
15335 {
15336 26570 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15337
15338
2/2
✓ Branch 0 taken 12096 times.
✓ Branch 1 taken 14474 times.
26570 if(x.getInt() & 7)
15339 12096 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15340 else
15341 14474 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15342
15343 26570 execute(info);
15344
15345
2/2
✓ Branch 0 taken 3191 times.
✓ Branch 1 taken 23379 times.
26570 if(info.isUnwalkable())
15346 {
15347
2/2
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 84 times.
3191 if(z3step==2)
15348 {
15349 3107 z3step=1;
15350 3107 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15351
15352
2/2
✓ Branch 0 taken 1821 times.
✓ Branch 1 taken 1286 times.
3107 if(x.getInt()&7)
15353 1286 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15354 else
15355 1821 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15356
15357 3107 execute(info);
15358
15359
2/2
✓ Branch 0 taken 2980 times.
✓ Branch 1 taken 127 times.
3107 if(info.isUnwalkable())
15360 {
15361 2980 walkable = false;
15362 2980 }
15363 else
15364 {
15365 127 walkable=true;
15366 }
15367 3107 }
15368 else
15369 {
15370 84 walkable=false;
15371 }
15372 3191 }
15373 else
15374 {
15375 23379 walkable = true;
15376 }
15377 }
15378
15379 42924 int32_t s=shiftdir;
15380
15381
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 42924 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
42924 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15382 {
15383 shiftdir=-1;
15384 }
15385 else
15386 {
15387
2/2
✓ Branch 0 taken 4016 times.
✓ Branch 1 taken 38908 times.
42924 if(s==left)
15388 {
15389 4016 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
15390 4016 execute(info);
15391
15392
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 3505 times.
4016 if(info.isUnwalkable())
15393 {
15394 511 shiftdir=-1;
15395 511 }
15396
2/2
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 2241 times.
3505 else if(walkable)
15397 {
15398 2241 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
15399 2241 execute(info);
15400
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 3 times.
2241 if(info.isUnwalkable())
15401 {
15402 3 shiftdir=-1;
15403 3 }
15404 2241 }
15405 4016 }
15406
2/2
✓ Branch 0 taken 33529 times.
✓ Branch 1 taken 5379 times.
38908 else if(s==right)
15407 {
15408 5379 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15409 5379 execute(info);
15410
15411
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 4599 times.
5379 if(info.isUnwalkable())
15412 {
15413 780 shiftdir=-1;
15414 780 }
15415
2/2
✓ Branch 0 taken 1732 times.
✓ Branch 1 taken 2867 times.
4599 else if(walkable)
15416 {
15417 2867 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
15418 2867 execute(info);
15419
15420
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 2 times.
2867 if(info.isUnwalkable())
15421 {
15422 2 shiftdir=-1;
15423 2 }
15424 2867 }
15425 5379 }
15426 }
15427
15428 42924 moveOld2(up);
15429 42924 shiftdir=s;
15430
15431
2/2
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 19418 times.
42924 if(!walkable)
15432 {
15433
2/2
✓ Branch 0 taken 3598 times.
✓ Branch 1 taken 15820 times.
19418 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15434 {
15435
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15820 times.
✓ Branch 2 taken 15820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2054 times.
✓ Branch 5 taken 13766 times.
✓ Branch 6 taken 159 times.
✓ Branch 7 taken 15661 times.
29586 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15436
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13766 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13766 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 13598 times.
13766 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15437
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13598 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13598 times.
13598 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15438 {
15439
5/8
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 159 times.
159 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15440 159 sprite::move((zfix)-1,(zfix)0);
15441 159 }
15442 else
15443 {
15444
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15661 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15661 times.
✓ Branch 4 taken 13607 times.
✓ Branch 5 taken 2054 times.
✓ Branch 6 taken 122 times.
✓ Branch 7 taken 15539 times.
17715 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15445
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054 times.
✓ Branch 4 taken 1932 times.
✓ Branch 5 taken 122 times.
2054 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15446
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
122 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15447 {
15448
5/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 122 times.
122 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15449 122 sprite::move((zfix)1,(zfix)0);
15450 122 }
15451 else
15452 {
15453 15539 pushing=push+1;
15454 }
15455 }
15456
15457 15820 z3step=2;
15458 15820 }
15459 else
15460 {
15461 3598 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15462 3598 z3step=2;
15463 }
15464 19418 }
15465
15466 42924 return;
15467 }
15468 }
15469
15470
6/6
✓ Branch 0 taken 37469 times.
✓ Branch 1 taken 433427 times.
✓ Branch 2 taken 36480 times.
✓ Branch 3 taken 989 times.
✓ Branch 4 taken 27508 times.
✓ Branch 5 taken 8972 times.
470896 if(DrunkDown()&&(holddir==-1||holddir==down))
15471 {
15472
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 28497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28497 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15473 {
15474 }
15475 else
15476 {
15477
2/4
✓ Branch 0 taken 28497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28497 times.
✗ Branch 3 not taken.
28497 if(charging==0 && spins==0)
15478 {
15479 28497 dir=down;
15480 28497 }
15481
15482 28497 holddir=down;
15483
15484
4/4
✓ Branch 0 taken 4174 times.
✓ Branch 1 taken 24323 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4170 times.
28497 if(DrunkRight()&&shiftdir!=left)
15485 {
15486 4170 shiftdir=right;
15487 4170 }
15488
4/4
✓ Branch 0 taken 3439 times.
✓ Branch 1 taken 20888 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3436 times.
24327 else if(DrunkLeft()&&shiftdir!=right)
15489 {
15490 3436 shiftdir=left;
15491 3436 }
15492 else
15493 {
15494 20891 shiftdir=-1;
15495 }
15496
15497 //bool walkable;
15498
7/12
✓ Branch 0 taken 9145 times.
✓ Branch 1 taken 19352 times.
✓ Branch 2 taken 9145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9145 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9145 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 9145 times.
28497 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15499 {
15500 9145 walkable=false;
15501 9145 }
15502 else
15503 {
15504 19352 info = walkflag(x,y+15+z3step,2,down);
15505
15506
2/2
✓ Branch 0 taken 9248 times.
✓ Branch 1 taken 10104 times.
19352 if(x.getInt()&7)
15507 9248 info = info || walkflag(x+16,y+15+z3step,1,down);
15508 else
15509 10104 info = info || walkflagMBlock(x+16, y+15+z3step);
15510
15511 19352 execute(info);
15512
15513
2/2
✓ Branch 0 taken 2393 times.
✓ Branch 1 taken 16959 times.
19352 if(info.isUnwalkable())
15514 {
15515
2/2
✓ Branch 0 taken 2327 times.
✓ Branch 1 taken 66 times.
2393 if(z3step==2)
15516 {
15517 2327 z3step=1;
15518 2327 info = walkflag(x,y+15+z3step,2,down);
15519
15520
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 1301 times.
2327 if(x.getInt()&7)
15521 1026 info = info || walkflag(x+16,y+15+z3step,1,down);
15522 else
15523 1301 info = info || walkflagMBlock(x+16, y+15+z3step);
15524
15525 2327 execute(info);
15526
15527
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 79 times.
2327 if(info.isUnwalkable())
15528 {
15529 2248 walkable = false;
15530 2248 }
15531 else
15532 {
15533 79 walkable=true;
15534 }
15535 2327 }
15536 else
15537 {
15538 66 walkable=false;
15539 }
15540 2393 }
15541 else
15542 {
15543 16959 walkable = true;
15544 }
15545 }
15546
15547 28497 int32_t s=shiftdir;
15548
15549
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28497 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15550 {
15551 shiftdir=-1;
15552 }
15553 else
15554 {
15555
2/2
✓ Branch 0 taken 3436 times.
✓ Branch 1 taken 25061 times.
28497 if(s==left)
15556 {
15557 3436 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
15558 3436 execute(info);
15559
15560
2/2
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 3043 times.
3436 if(info.isUnwalkable())
15561 {
15562 393 shiftdir=-1;
15563 393 }
15564
2/2
✓ Branch 0 taken 1343 times.
✓ Branch 1 taken 1700 times.
3043 else if(walkable)
15565 {
15566 1700 info = walkflag(x-1,y+16,1,left);
15567 1700 execute(info);
15568
15569
2/2
✓ Branch 0 taken 1696 times.
✓ Branch 1 taken 4 times.
1700 if(info.isUnwalkable())
15570 {
15571 4 shiftdir=-1;
15572 4 }
15573 1700 }
15574 3436 }
15575
2/2
✓ Branch 0 taken 20891 times.
✓ Branch 1 taken 4170 times.
25061 else if(s==right)
15576 {
15577 4170 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15578 4170 execute(info);
15579
15580
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 3609 times.
4170 if(info.isUnwalkable())
15581 {
15582 561 shiftdir=-1;
15583 561 }
15584
2/2
✓ Branch 0 taken 1112 times.
✓ Branch 1 taken 2497 times.
3609 else if(walkable)
15585 {
15586 2497 info = walkflag(x+16,y+16,1,right);
15587 2497 execute(info);
15588
15589
2/2
✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 9 times.
2497 if(info.isUnwalkable())
15590 {
15591 9 shiftdir=-1;
15592 9 }
15593 2497 }
15594 4170 }
15595 }
15596
15597 28497 moveOld2(down);
15598 28497 shiftdir=s;
15599
15600
2/2
✓ Branch 0 taken 17038 times.
✓ Branch 1 taken 11459 times.
28497 if(!walkable)
15601 {
15602
2/2
✓ Branch 0 taken 2736 times.
✓ Branch 1 taken 8723 times.
11459 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15603 {
15604
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8723 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8723 times.
✓ Branch 4 taken 3004 times.
✓ Branch 5 taken 5719 times.
✓ Branch 6 taken 115 times.
✓ Branch 7 taken 8608 times.
14442 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15605
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5719 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5719 times.
✓ Branch 4 taken 172 times.
✓ Branch 5 taken 5547 times.
5719 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15606
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5547 times.
5547 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15607 {
15608
4/8
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 115 times.
115 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15609 115 sprite::move((zfix)-1,(zfix)0);
15610 115 }
15611
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8608 times.
✓ Branch 4 taken 5604 times.
✓ Branch 5 taken 3004 times.
✓ Branch 6 taken 123 times.
✓ Branch 7 taken 8485 times.
11612 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15612
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3004 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3004 times.
✓ Branch 4 taken 2881 times.
✓ Branch 5 taken 123 times.
3004 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15613
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
123 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15614 {
15615
5/8
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 123 times.
123 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15616 123 sprite::move((zfix)1,(zfix)0);
15617 123 }
15618 else //if(shiftdir==-1)
15619 {
15620 8485 pushing=push+1;
15621
15622
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 8444 times.
8485 if(action!=swimming)
15623 {
15624 8444 }
15625 }
15626
15627 8723 z3step=2;
15628 8723 }
15629 else
15630 {
15631 2736 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15632
15633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2736 times.
2736 if(action!=swimming)
15634 {
15635 2736 }
15636
15637 2736 z3step=2;
15638 }
15639 11459 }
15640
15641 28497 return;
15642 }
15643 }
15644
15645
6/6
✓ Branch 0 taken 111365 times.
✓ Branch 1 taken 331034 times.
✓ Branch 2 taken 108136 times.
✓ Branch 3 taken 3229 times.
✓ Branch 4 taken 108035 times.
✓ Branch 5 taken 101 times.
442399 if(DrunkLeft()&&(holddir==-1||holddir==left))
15646 {
15647
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 111264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
111264 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15648 {
15649 }
15650 else
15651 {
15652
2/4
✓ Branch 0 taken 111264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 111264 times.
111264 if(charging==0 && spins==0)
15653 {
15654 111264 dir=left;
15655 111264 }
15656
15657 111264 holddir=left;
15658
15659
4/4
✓ Branch 0 taken 5464 times.
✓ Branch 1 taken 105800 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 5463 times.
111264 if(DrunkUp()&&shiftdir!=down)
15660 {
15661 5463 shiftdir=up;
15662 5463 }
15663
3/4
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 101747 times.
✓ Branch 2 taken 4054 times.
✗ Branch 3 not taken.
105801 else if(DrunkDown()&&shiftdir!=up)
15664 {
15665 4054 shiftdir=down;
15666 4054 }
15667 else
15668 {
15669 101747 shiftdir=-1;
15670 }
15671
15672 //bool walkable;
15673 111264 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15674
15675
2/2
✓ Branch 0 taken 70635 times.
✓ Branch 1 taken 40629 times.
111264 if(y.getInt()&7)
15676 40629 info = info || walkflag(x-z3step,y+16,1,left);
15677
15678 111264 execute(info);
15679
15680
2/2
✓ Branch 0 taken 13124 times.
✓ Branch 1 taken 98140 times.
111264 if(info.isUnwalkable())
15681 {
15682
2/2
✓ Branch 0 taken 12864 times.
✓ Branch 1 taken 260 times.
13124 if(z3step==2)
15683 {
15684 12864 z3step=1;
15685 12864 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15686
15687
2/2
✓ Branch 0 taken 4993 times.
✓ Branch 1 taken 7871 times.
12864 if(y.getInt()&7)
15688 4993 info = info || walkflag(x-z3step,y+16,1,left);
15689
15690 12864 execute(info);
15691
15692
2/2
✓ Branch 0 taken 12595 times.
✓ Branch 1 taken 269 times.
12864 if(info.isUnwalkable())
15693 {
15694 12595 walkable = false;
15695 12595 }
15696 else
15697 {
15698 269 walkable=true;
15699 }
15700 12864 }
15701 else
15702 {
15703 260 walkable=false;
15704 }
15705 13124 }
15706 else
15707 {
15708 98140 walkable = true;
15709 }
15710
15711 111264 int32_t s=shiftdir;
15712
15713
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 111264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56334 times.
✓ Branch 7 taken 54930 times.
✓ Branch 8 taken 56334 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56334 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 56334 times.
✗ Branch 13 not taken.
111264 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15714 {
15715 56334 shiftdir=-1;
15716 56334 }
15717 else
15718 {
15719
2/2
✓ Branch 0 taken 50758 times.
✓ Branch 1 taken 4172 times.
54930 if(s==up)
15720 {
15721 4172 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15722 4172 execute(info);
15723
15724
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 3772 times.
4172 if(info.isUnwalkable())
15725 {
15726 400 shiftdir=-1;
15727 400 }
15728
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 3462 times.
3772 else if(walkable)
15729 {
15730 3462 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
15731 3462 execute(info);
15732
15733
2/2
✓ Branch 0 taken 3458 times.
✓ Branch 1 taken 4 times.
3462 if(info.isUnwalkable())
15734 {
15735 4 shiftdir=-1;
15736 4 }
15737 3462 }
15738 4172 }
15739
2/2
✓ Branch 0 taken 47265 times.
✓ Branch 1 taken 3493 times.
50758 else if(s==down)
15740 {
15741 3493 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15742 3493 execute(info);
15743
15744
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 3107 times.
3493 if(info.isUnwalkable())
15745 {
15746 386 shiftdir=-1;
15747 386 }
15748
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2826 times.
3107 else if(walkable)
15749 {
15750 2826 info = walkflag(x-1,y+16,1,down);
15751 2826 execute(info);
15752
15753
2/2
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 3 times.
2826 if(info.isUnwalkable())
15754 {
15755 3 shiftdir=-1;
15756 3 }
15757 2826 }
15758 3493 }
15759 }
15760
15761 111264 moveOld2(left);
15762 111264 shiftdir=s;
15763
15764
2/2
✓ Branch 0 taken 98409 times.
✓ Branch 1 taken 12855 times.
111264 if(!walkable)
15765 {
15766
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 11923 times.
12855 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15767 {
15768 11923 int32_t v1=bigHitbox?0:8;
15769 11923 int32_t v2=bigHitbox?8:12;
15770
15771
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11923 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11923 times.
✓ Branch 4 taken 10609 times.
✓ Branch 5 taken 1314 times.
✓ Branch 6 taken 621 times.
✓ Branch 7 taken 11302 times.
13237 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15772
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1314 times.
✓ Branch 2 taken 1314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 621 times.
1314 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15773
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 621 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 621 times.
621 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15774 {
15775
5/8
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 540 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 540 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 621 times.
621 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15776 621 sprite::move((zfix)0,(zfix)-1);
15777 621 }
15778
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11302 times.
✓ Branch 2 taken 11302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 10609 times.
✓ Branch 6 taken 224 times.
✓ Branch 7 taken 11078 times.
21911 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15779
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10609 times.
✓ Branch 4 taken 10385 times.
✓ Branch 5 taken 224 times.
10609 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15780
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 224 times.
224 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15781 {
15782
6/8
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 181 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 223 times.
224 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15783 223 sprite::move((zfix)0,(zfix)1);
15784 224 }
15785 else //if(shiftdir==-1)
15786 {
15787 11078 pushing=push+1;
15788
15789
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 11030 times.
11078 if(action!=swimming)
15790 {
15791 11030 }
15792 }
15793
15794 11923 z3step=2;
15795 11923 }
15796 else
15797 {
15798 932 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15799
15800
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 923 times.
932 if(action!=swimming)
15801 {
15802 923 }
15803
15804 932 z3step=2;
15805 }
15806 12855 }
15807
15808 111264 return;
15809 }
15810 }
15811
15812
5/6
✓ Branch 0 taken 134155 times.
✓ Branch 1 taken 196980 times.
✓ Branch 2 taken 130485 times.
✓ Branch 3 taken 3670 times.
✓ Branch 4 taken 130485 times.
✗ Branch 5 not taken.
331135 if(DrunkRight()&&(holddir==-1||holddir==right))
15813 {
15814
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 134155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
134155 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15815 {
15816 }
15817 else
15818 {
15819
2/4
✓ Branch 0 taken 134155 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 134155 times.
134155 if(charging==0 && spins==0)
15820 {
15821 134155 dir=right;
15822 134155 }
15823
15824 134155 holddir=right;
15825
15826
4/4
✓ Branch 0 taken 6952 times.
✓ Branch 1 taken 127203 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 6951 times.
134155 if(DrunkUp()&&shiftdir!=down)
15827 {
15828 6951 shiftdir=up;
15829 6951 }
15830
3/4
✓ Branch 0 taken 4918 times.
✓ Branch 1 taken 122286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4918 times.
127204 else if(DrunkDown()&&shiftdir!=up)
15831 {
15832 4918 shiftdir=down;
15833 4918 }
15834 else
15835 {
15836 122286 shiftdir=-1;
15837 }
15838
15839 //bool walkable;
15840 134155 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15841
15842
2/2
✓ Branch 0 taken 85264 times.
✓ Branch 1 taken 48891 times.
134155 if(y.getInt()&7)
15843 48891 info = info || walkflag(x+15+z3step,y+16,1,right);
15844
15845 134155 execute(info);
15846
15847
2/2
✓ Branch 0 taken 14498 times.
✓ Branch 1 taken 119657 times.
134155 if(info.isUnwalkable())
15848 {
15849
2/2
✓ Branch 0 taken 14220 times.
✓ Branch 1 taken 278 times.
14498 if(z3step==2)
15850 {
15851 14220 z3step=1;
15852 14220 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15853
15854
2/2
✓ Branch 0 taken 6842 times.
✓ Branch 1 taken 7378 times.
14220 if(y.getInt()&7)
15855 6842 info = info || walkflag(x+15+z3step,y+16,1,right);
15856
15857 14220 execute(info);
15858
15859
2/2
✓ Branch 0 taken 13818 times.
✓ Branch 1 taken 402 times.
14220 if(info.isUnwalkable())
15860 {
15861 13818 walkable = false;
15862 13818 }
15863 else
15864 {
15865 402 walkable=true;
15866 }
15867 14220 }
15868 else
15869 {
15870 278 walkable=false;
15871 }
15872 14498 }
15873 else
15874 {
15875 119657 walkable = true;
15876 }
15877
15878 134155 int32_t s=shiftdir;
15879
15880
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 134155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 65926 times.
✓ Branch 7 taken 68229 times.
✓ Branch 8 taken 65926 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 65926 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 65926 times.
✗ Branch 13 not taken.
134155 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15881 {
15882 65926 shiftdir=-1;
15883 65926 }
15884 else
15885 {
15886
2/2
✓ Branch 0 taken 63040 times.
✓ Branch 1 taken 5189 times.
68229 if(s==up)
15887 {
15888 5189 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15889 5189 execute(info);
15890
15891
2/2
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 4810 times.
5189 if(info.isUnwalkable())
15892 {
15893 379 shiftdir=-1;
15894 379 }
15895
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 4416 times.
4810 else if(walkable)
15896 {
15897 4416 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
15898 4416 execute(info);
15899
15900
2/2
✓ Branch 0 taken 4409 times.
✓ Branch 1 taken 7 times.
4416 if(info.isUnwalkable())
15901 {
15902 7 shiftdir=-1;
15903 7 }
15904 4416 }
15905 5189 }
15906
2/2
✓ Branch 0 taken 58599 times.
✓ Branch 1 taken 4441 times.
63040 else if(s==down)
15907 {
15908 4441 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15909 4441 execute(info);
15910
15911
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 3827 times.
4441 if(info.isUnwalkable())
15912 {
15913 614 shiftdir=-1;
15914 614 }
15915
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 3377 times.
3827 else if(walkable)
15916 {
15917 3377 info = walkflag(x+16,y+16,1,down);
15918 3377 execute(info);
15919
15920
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 14 times.
3377 if(info.isUnwalkable())
15921 {
15922 14 shiftdir=-1;
15923 14 }
15924 3377 }
15925 4441 }
15926 }
15927
15928 134155 moveOld2(right);
15929 134155 shiftdir=s;
15930
15931
2/2
✓ Branch 0 taken 120059 times.
✓ Branch 1 taken 14096 times.
134155 if(!walkable)
15932 {
15933
2/2
✓ Branch 0 taken 1415 times.
✓ Branch 1 taken 12681 times.
14096 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15934 {
15935 12681 int32_t v1=bigHitbox?0:8;
15936 12681 int32_t v2=bigHitbox?8:12;
15937
15938 38043 info = !walkflag(x+16,y+v1,1,right)&&
15939 25362 !walkflag(x+16,y+v2,1,right)&&
15940 12681 walkflag(x+16,y+15,1,right);
15941
15942 //do NOT execute these
15943
2/2
✓ Branch 0 taken 930 times.
✓ Branch 1 taken 11751 times.
12681 if(info.isUnwalkable())
15944 {
15945
6/8
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 905 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 905 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 929 times.
930 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15946 929 sprite::move((zfix)0,(zfix)-1);
15947 930 }
15948 else
15949 {
15950 35253 info = walkflag(x+16,y+v1, 1,right)&&
15951 23502 !walkflag(x+16,y+v2-1,1,right)&&
15952 11751 !walkflag(x+16,y+15, 1,right);
15953
15954
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 11437 times.
11751 if(info.isUnwalkable())
15955 {
15956
5/8
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 299 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 314 times.
314 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15957 314 sprite::move((zfix)0,(zfix)1);
15958 314 }
15959 else //if(shiftdir==-1)
15960 {
15961 11437 pushing=push+1;
15962 11437 z3step=2;
15963
15964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11437 times.
11437 if(action!=swimming)
15965 {
15966 11437 }
15967 }
15968 }
15969
15970 12681 z3step=2;
15971 12681 }
15972 else
15973 {
15974 1415 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15975
15976
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1409 times.
1415 if(action!=swimming)
15977 {
15978 1409 }
15979
15980 1415 z3step=2;
15981 }
15982 14096 }
15983
15984 134155 return;
15985 }
15986 }
15987 }
15988
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 243510 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
243510 if(shield_forcedir > -1 && action != rafting)
15989 dir = shield_forcedir;
15990 243510 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
15991 243510 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
15992 243510 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
15993 243510 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
15994 243510 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
15995
15996
8/12
✓ Branch 0 taken 70324 times.
✓ Branch 1 taken 173186 times.
✓ Branch 2 taken 70324 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 70324 times.
✓ Branch 6 taken 70324 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 67541 times.
✓ Branch 9 taken 2783 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 67541 times.
243510 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
15997 {
15998
8/12
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 67340 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 152 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 152 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
67541 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
15999 {
16000 //action=swimming;
16001
3/12
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
152 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
16002 {
16003 hopclk = 0xFF;
16004 }
16005 152 }
16006 67541 }
16007
16008 243510 return;
16009 } //endif (LTTPWALK)
16010 2329599 temp_step = hero_newstep;
16011 2329599 temp_x = x;
16012 2329599 temp_y = y;
16013
16014
7/8
✓ Branch 0 taken 1488191 times.
✓ Branch 1 taken 841408 times.
✓ Branch 2 taken 1456800 times.
✓ Branch 3 taken 31391 times.
✓ Branch 4 taken 43770 times.
✓ Branch 5 taken 1444421 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 43770 times.
2329599 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16015 {
16016
2/4
✓ Branch 0 taken 43770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43770 times.
43770 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16017 goto LEFTRIGHT_NEWMOVE;
16018 43770 else goto LEFTRIGHT_OLDMOVE;
16019 }
16020
16021 // make it easier to get in left & right doors
16022
16023 //ignore ladder for this part. sigh sigh sigh -DD
16024 2285829 oldladderx = ladderx;
16025 2285829 oldladdery = laddery;
16026
2/4
✓ Branch 0 taken 2285829 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2285829 times.
2285829 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16027 {
16028 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
16029 {
16030 do
16031 {
16032 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
16033 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
16034
16035 if(info.isUnwalkable())
16036 {
16037 if(temp_x != int32_t(temp_x))
16038 {
16039 temp_x = floor((double)temp_x);
16040 }
16041 else if(temp_step > 1)
16042 {
16043 if(temp_step != int32_t(temp_step)) //floor
16044 temp_step = floor((double)temp_step);
16045 else --temp_step;
16046 }
16047 else
16048 break;
16049 }
16050 }
16051 while(info.isUnwalkable());
16052
16053 if(!info.isUnwalkable())
16054 {
16055 x = temp_x;
16056 y = temp_y;
16057 hero_newstep = temp_step;
16058 //ONLY process the side-effects of the above walkflag if Hero will actually move
16059 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16060 execute(info);
16061 moveOld2(left);
16062 return;
16063 }
16064 temp_x = x;
16065 temp_y = y;
16066 temp_step = hero_newstep;
16067 }
16068
16069 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
16070 {
16071 do
16072 {
16073 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16074 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
16075
16076 if(info.isUnwalkable())
16077 {
16078 if(temp_x != int32_t(temp_x))
16079 {
16080 temp_x = floor((double)temp_x);
16081 }
16082 else if(temp_step > 1)
16083 {
16084 if(temp_step != int32_t(temp_step)) //floor
16085 temp_step = floor((double)temp_step);
16086 else --temp_step;
16087 }
16088 else
16089 break;
16090 }
16091 }
16092 while(info.isUnwalkable());
16093
16094 if(!info.isUnwalkable())
16095 {
16096 x = temp_x;
16097 y = temp_y;
16098 hero_newstep = temp_step;
16099 execute(info);
16100 moveOld2(right);
16101 return;
16102 }
16103 temp_x = x;
16104 temp_y = y;
16105 temp_step = hero_newstep;
16106 }
16107
16108 ladderx = oldladderx;
16109 laddery = oldladdery;
16110
16111 if(DrunkUp())
16112 {
16113 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16114 {
16115 if(dir!=up && dir!=down)
16116 {
16117 if(xoff>2&&xoff<6)
16118 {
16119 moveOld2(dir);
16120 }
16121 else if(xoff>=6)
16122 {
16123 moveOld2(right);
16124 }
16125 else if(xoff>=1)
16126 {
16127 moveOld2(left);
16128 }
16129 }
16130 else
16131 {
16132 if(xoff>=4)
16133 {
16134 moveOld2(right);
16135 }
16136 else if(xoff<4)
16137 {
16138 moveOld2(left);
16139 }
16140 }
16141 }
16142 else
16143 {
16144 do
16145 {
16146 if(action==swimming || IsSideSwim() || action == swimhit)
16147 {
16148 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
16149
16150 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
16151 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
16152 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
16153 info.setUnwalkable(true);
16154 }
16155 else
16156 {
16157 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
16158 if(x.getInt() & 7)
16159 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
16160 else
16161 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
16162 }
16163
16164 if(info.isUnwalkable())
16165 {
16166 if(temp_y != int32_t(temp_y))
16167 {
16168 temp_y = floor((double)temp_y);
16169 }
16170 else if(temp_step > 1)
16171 {
16172 if(temp_step != int32_t(temp_step)) //floor
16173 temp_step = floor((double)temp_step);
16174 else --temp_step;
16175 }
16176 else
16177 break;
16178 }
16179 }
16180 while(info.isUnwalkable());
16181
16182 execute(info);
16183
16184 if(!info.isUnwalkable())
16185 {
16186 x = temp_x;
16187 y = temp_y;
16188 hero_newstep = temp_step;
16189 moveOld2(up);
16190 return;
16191 }
16192
16193 if(!DrunkLeft() && !DrunkRight())
16194 {
16195 if(NO_GRIDLOCK)
16196 {
16197 x = x.getInt();
16198 y = y.getInt();
16199 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16200 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16201 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16202 {
16203 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16204 sprite::move((zfix)-1,(zfix)0);
16205 }
16206 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16207 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16208 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16209 {
16210 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16211 sprite::move((zfix)1,(zfix)0);
16212 }
16213 else
16214 {
16215 pushing=push+1;
16216 }
16217 }
16218 else pushing=push+1;
16219
16220 if(charging==0 && spins==0)
16221 {
16222 dir=up;
16223 }
16224
16225 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16226 {
16227 herostep();
16228 }
16229
16230 return;
16231 }
16232 else
16233 {
16234 goto LEFTRIGHT_NEWMOVE;
16235 }
16236 }
16237
16238 return;
16239 }
16240
16241 if(DrunkDown())
16242 {
16243 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16244 {
16245 if(dir!=up && dir!=down)
16246 {
16247 if(xoff>2&&xoff<6)
16248 {
16249 moveOld2(dir);
16250 }
16251 else if(xoff>=6)
16252 {
16253 moveOld2(right);
16254 }
16255 else if(xoff>=1)
16256 {
16257 moveOld2(left);
16258 }
16259 }
16260 else
16261 {
16262 if(xoff>=4)
16263 {
16264 moveOld2(right);
16265 }
16266 else if(xoff<4)
16267 {
16268 moveOld2(left);
16269 }
16270 }
16271 }
16272 else
16273 {
16274 do
16275 {
16276 if(action==swimming || IsSideSwim() || action == swimhit)
16277 {
16278 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16279
16280 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
16281 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
16282 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
16283 info.setUnwalkable(true);
16284 }
16285 else
16286 {
16287 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16288 if(x.getInt() & 7)
16289 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
16290 else
16291 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
16292 }
16293
16294 if(info.isUnwalkable())
16295 {
16296 if(temp_y != int32_t(temp_y))
16297 {
16298 temp_y = floor((double)temp_y);
16299 }
16300 else if(temp_step > 1)
16301 {
16302 if(temp_step != int32_t(temp_step)) //floor
16303 temp_step = floor((double)temp_step);
16304 else --temp_step;
16305 }
16306 else
16307 break;
16308 }
16309 }
16310 while(info.isUnwalkable());
16311
16312 execute(info);
16313
16314 if(!info.isUnwalkable())
16315 {
16316 x = temp_x;
16317 y = temp_y;
16318 hero_newstep = temp_step;
16319 moveOld2(down);
16320 return;
16321 }
16322
16323 if(!DrunkLeft() && !DrunkRight())
16324 {
16325 if(NO_GRIDLOCK)
16326 {
16327 x = x.getInt();
16328 y = y.getInt();
16329 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16330 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16331 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16332 {
16333 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16334 sprite::move((zfix)-1,(zfix)0);
16335 }
16336 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16337 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16338 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16339 {
16340 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16341 sprite::move((zfix)1,(zfix)0);
16342 }
16343 else
16344 {
16345 pushing=push+1;
16346 }
16347 }
16348 else pushing=push+1;
16349
16350 if(charging==0 && spins==0)
16351 {
16352 dir=down;
16353 }
16354
16355 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16356 {
16357 herostep();
16358 }
16359
16360 return;
16361 }
16362 else goto LEFTRIGHT_NEWMOVE;
16363 }
16364
16365 return;
16366 }
16367
16368 LEFTRIGHT_NEWMOVE:
16369 temp_x = x;
16370 temp_y = y;
16371 temp_step = hero_newstep;
16372 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16373 {
16374 return;
16375 }
16376
16377 if(DrunkLeft())
16378 {
16379 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16380 {
16381 if(dir!=left && dir!=right)
16382 {
16383 if(yoff>2&&yoff<6)
16384 {
16385 moveOld2(dir);
16386 }
16387 else if(yoff>=6)
16388 {
16389 moveOld2(down);
16390 }
16391 else if(yoff>=1)
16392 {
16393 moveOld2(up);
16394 }
16395 }
16396 else
16397 {
16398 if(yoff>=4)
16399 {
16400 moveOld2(down);
16401 }
16402 else if(yoff<4)
16403 {
16404 moveOld2(up);
16405 }
16406 }
16407 }
16408 else
16409 {
16410 do
16411 {
16412 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
16413 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
16414
16415 if(y.getInt() & 7)
16416 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
16417
16418 if(info.isUnwalkable())
16419 {
16420 if(temp_x != int32_t(temp_x))
16421 {
16422 temp_x = floor((double)temp_x);
16423 }
16424 else if(temp_step > 1)
16425 {
16426 if(temp_step != int32_t(temp_step)) //floor
16427 temp_step = floor((double)temp_step);
16428 else --temp_step;
16429 }
16430 else
16431 break;
16432 }
16433 }
16434 while(info.isUnwalkable());
16435
16436 execute(info);
16437
16438 if(!info.isUnwalkable())
16439 {
16440 x = temp_x;
16441 y = temp_y;
16442 hero_newstep = temp_step;
16443 moveOld2(left);
16444 return;
16445 }
16446
16447 if(!DrunkUp() && !DrunkDown())
16448 {
16449 if(NO_GRIDLOCK)
16450 {
16451 x = x.getInt();
16452 y = y.getInt();
16453 int32_t v1=bigHitbox?0:8;
16454 int32_t v2=bigHitbox?8:12;
16455
16456 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16457 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16458 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16459 {
16460 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16461 sprite::move((zfix)0,(zfix)-1);
16462 }
16463 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16464 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16465 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16466 {
16467 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16468 sprite::move((zfix)0,(zfix)1);
16469 }
16470 else
16471 {
16472 pushing=push+1;
16473 }
16474 }
16475 else pushing=push+1;
16476
16477 if(charging==0 && spins==0)
16478 {
16479 dir=left;
16480 }
16481
16482 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16483 {
16484 herostep();
16485 }
16486
16487 return;
16488 }
16489 }
16490
16491 return;
16492 }
16493
16494 if(DrunkRight())
16495 {
16496 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16497 {
16498 if(dir!=left && dir!=right)
16499 {
16500 if(yoff>2&&yoff<6)
16501 {
16502 moveOld2(dir);
16503 }
16504 else if(yoff>=6)
16505 {
16506 moveOld2(down);
16507 }
16508 else if(yoff>=1)
16509 {
16510 moveOld2(up);
16511 }
16512 }
16513 else
16514 {
16515 if(yoff>=4)
16516 {
16517 moveOld2(down);
16518 }
16519 else if(yoff<4)
16520 {
16521 moveOld2(up);
16522 }
16523 }
16524 }
16525 else
16526 {
16527 do
16528 {
16529 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16530 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
16531
16532 if(y.getInt() & 7)
16533 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
16534
16535 if(info.isUnwalkable())
16536 {
16537 if(temp_x != int32_t(temp_x))
16538 {
16539 temp_x = floor((double)temp_x);
16540 }
16541 else if(temp_step > 1)
16542 {
16543 if(temp_step != int32_t(temp_step)) //floor
16544 temp_step = floor((double)temp_step);
16545 else --temp_step;
16546 }
16547 else
16548 break;
16549 }
16550 }
16551 while(info.isUnwalkable());
16552
16553 execute(info);
16554
16555 if(!info.isUnwalkable())
16556 {
16557 x = temp_x;
16558 y = temp_y;
16559 hero_newstep = temp_step;
16560 moveOld2(right);
16561 return;
16562 }
16563
16564 if(!DrunkUp() && !DrunkDown())
16565 {
16566 if(NO_GRIDLOCK)
16567 {
16568 x = x.getInt();
16569 y = y.getInt();
16570 int32_t v1=bigHitbox?0:8;
16571 int32_t v2=bigHitbox?8:12;
16572
16573 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16574 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16575 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16576 {
16577 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16578 sprite::move((zfix)0,(zfix)-1);
16579 }
16580 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16581 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16582 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16583 {
16584 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16585 sprite::move((zfix)0,(zfix)1);
16586 }
16587 else
16588 {
16589 pushing=push+1;
16590 }
16591 }
16592 else pushing=push+1;
16593
16594 if(charging==0 && spins==0)
16595 {
16596 dir=right;
16597 }
16598
16599 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16600 {
16601 herostep();
16602 }
16603
16604 return;
16605 }
16606 }
16607 }
16608 }
16609 else
16610 {
16611 4571658 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16612 2285829 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
16613
16614
10/10
✓ Branch 0 taken 1444421 times.
✓ Branch 1 taken 841408 times.
✓ Branch 2 taken 178265 times.
✓ Branch 3 taken 1266156 times.
✓ Branch 4 taken 102611 times.
✓ Branch 5 taken 75654 times.
✓ Branch 6 taken 927 times.
✓ Branch 7 taken 101684 times.
✓ Branch 8 taken 842 times.
✓ Branch 9 taken 85 times.
2285829 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
16615 {
16616 //ONLY process the side-effects of the above walkflag if Hero will actually move
16617 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16618 842 execute(info);
16619 842 moveOld2(left);
16620 842 return;
16621 }
16622
16623 4569974 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
16624 2284987 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
16625
16626
10/10
✓ Branch 0 taken 1443579 times.
✓ Branch 1 taken 841408 times.
✓ Branch 2 taken 198489 times.
✓ Branch 3 taken 1245090 times.
✓ Branch 4 taken 111526 times.
✓ Branch 5 taken 86963 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 110380 times.
✓ Branch 8 taken 88 times.
✓ Branch 9 taken 1058 times.
2284987 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
16627 {
16628 1058 execute(info);
16629 1058 moveOld2(right);
16630 1058 return;
16631 }
16632
16633 2283929 ladderx = oldladderx;
16634 2283929 laddery = oldladdery;
16635
16636
2/2
✓ Branch 0 taken 246085 times.
✓ Branch 1 taken 2037844 times.
2283929 if(DrunkUp())
16637 {
16638
11/14
✓ Branch 0 taken 6732 times.
✓ Branch 1 taken 239353 times.
✓ Branch 2 taken 6279 times.
✓ Branch 3 taken 453 times.
✓ Branch 4 taken 5253 times.
✓ Branch 5 taken 1026 times.
✓ Branch 6 taken 5253 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5253 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5253 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 5250 times.
246085 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16639 {
16640
3/4
✓ Branch 0 taken 5217 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5217 times.
5250 if(dir!=up && dir!=down)
16641 {
16642
4/4
✓ Branch 0 taken 3611 times.
✓ Branch 1 taken 1606 times.
✓ Branch 2 taken 1553 times.
✓ Branch 3 taken 2058 times.
5217 if(xoff>2&&xoff<6)
16643 {
16644 2058 moveOld2(dir);
16645 2058 }
16646
2/2
✓ Branch 0 taken 1553 times.
✓ Branch 1 taken 1606 times.
3159 else if(xoff>=6)
16647 {
16648 1553 moveOld2(right);
16649 1553 }
16650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1606 times.
1606 else if(xoff>=1)
16651 {
16652 1606 moveOld2(left);
16653 1606 }
16654 5217 }
16655 else
16656 {
16657
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 if(xoff>=4)
16658 {
16659 10 moveOld2(right);
16660 10 }
16661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 else if(xoff<4)
16662 {
16663 23 moveOld2(left);
16664 23 }
16665 }
16666 5250 }
16667 else
16668 {
16669
4/6
✓ Branch 0 taken 229449 times.
✓ Branch 1 taken 11386 times.
✓ Branch 2 taken 229449 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 229449 times.
240835 if(action==swimming || IsSideSwim() || action == swimhit)
16670 {
16671 11386 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16672
16673
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11386 times.
✓ Branch 4 taken 944 times.
✓ Branch 5 taken 10442 times.
✓ Branch 6 taken 8870 times.
✓ Branch 7 taken 2516 times.
21828 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16674
2/2
✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 7954 times.
18396 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
16675 7954 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
16676 2516 info.setUnwalkable(true);
16677 11386 }
16678 else
16679 {
16680 229449 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16681
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 228992 times.
229449 if(x.getInt() & 7)
16682 457 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
16683 else
16684 228992 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
16685 }
16686
16687 240835 execute(info);
16688
16689
2/2
✓ Branch 0 taken 109203 times.
✓ Branch 1 taken 131632 times.
240835 if(!info.isUnwalkable())
16690 {
16691 131632 moveOld2(up);
16692 131632 return;
16693 }
16694
16695
4/4
✓ Branch 0 taken 98281 times.
✓ Branch 1 taken 10922 times.
✓ Branch 2 taken 11154 times.
✓ Branch 3 taken 87127 times.
109203 if(!DrunkLeft() && !DrunkRight())
16696 {
16697
2/4
✓ Branch 0 taken 87127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87127 times.
✗ Branch 3 not taken.
87127 if(NO_GRIDLOCK)
16698 {
16699 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16700 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16701 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16702 {
16703 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16704 sprite::move((zfix)-1,(zfix)0);
16705 }
16706 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16707 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16708 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16709 {
16710 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16711 sprite::move((zfix)1,(zfix)0);
16712 }
16713 else
16714 {
16715 pushing=push+1;
16716 }
16717 }
16718 87127 else pushing=push+1;
16719
16720
4/4
✓ Branch 0 taken 86944 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 86848 times.
✓ Branch 3 taken 96 times.
87127 if(charging==0 && spins==0)
16721 {
16722 86848 dir=up;
16723 86848 }
16724
16725
5/8
✓ Branch 0 taken 85227 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 85227 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85227 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 85227 times.
87127 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16726 {
16727 85227 herostep();
16728 85227 }
16729
16730 87127 return;
16731 }
16732 else
16733 {
16734 22076 goto LEFTRIGHT_OLDMOVE;
16735 }
16736 }
16737
16738 5250 return;
16739 }
16740
16741
2/2
✓ Branch 0 taken 217341 times.
✓ Branch 1 taken 1820503 times.
2037844 if(DrunkDown())
16742 {
16743
11/14
✓ Branch 0 taken 6486 times.
✓ Branch 1 taken 210855 times.
✓ Branch 2 taken 6213 times.
✓ Branch 3 taken 273 times.
✓ Branch 4 taken 4178 times.
✓ Branch 5 taken 2035 times.
✓ Branch 6 taken 4178 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4178 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4178 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 4177 times.
217341 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16744 {
16745
3/4
✓ Branch 0 taken 4177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4176 times.
4177 if(dir!=up && dir!=down)
16746 {
16747
4/4
✓ Branch 0 taken 2932 times.
✓ Branch 1 taken 1244 times.
✓ Branch 2 taken 1236 times.
✓ Branch 3 taken 1696 times.
4176 if(xoff>2&&xoff<6)
16748 {
16749 1696 moveOld2(dir);
16750 1696 }
16751
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 1244 times.
2480 else if(xoff>=6)
16752 {
16753 1236 moveOld2(right);
16754 1236 }
16755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1244 times.
1244 else if(xoff>=1)
16756 {
16757 1244 moveOld2(left);
16758 1244 }
16759 4176 }
16760 else
16761 {
16762
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(xoff>=4)
16763 {
16764 1 moveOld2(right);
16765 1 }
16766 else if(xoff<4)
16767 {
16768 moveOld2(left);
16769 }
16770 }
16771 4177 }
16772 else
16773 {
16774
4/6
✓ Branch 0 taken 200600 times.
✓ Branch 1 taken 12564 times.
✓ Branch 2 taken 200600 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 200600 times.
213164 if(action==swimming || IsSideSwim() || action == swimhit)
16775 {
16776 12564 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16777
16778
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 12564 times.
✓ Branch 2 taken 12564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 893 times.
✓ Branch 5 taken 11671 times.
✓ Branch 6 taken 8139 times.
✓ Branch 7 taken 4425 times.
24235 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16779
2/2
✓ Branch 0 taken 4353 times.
✓ Branch 1 taken 7318 times.
18989 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
16780 7318 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
16781 4425 info.setUnwalkable(true);
16782 12564 }
16783 else
16784 {
16785 200600 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16786
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 200325 times.
200600 if(x.getInt() & 7)
16787 275 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
16788 else
16789 200325 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
16790 }
16791
16792 213164 execute(info);
16793
16794
2/2
✓ Branch 0 taken 103643 times.
✓ Branch 1 taken 109521 times.
213164 if(!info.isUnwalkable())
16795 {
16796 109521 moveOld2(down);
16797 109521 return;
16798 }
16799
16800
4/4
✓ Branch 0 taken 91876 times.
✓ Branch 1 taken 11767 times.
✓ Branch 2 taken 11308 times.
✓ Branch 3 taken 80568 times.
103643 if(!DrunkLeft() && !DrunkRight())
16801 {
16802
2/4
✓ Branch 0 taken 80568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80568 times.
✗ Branch 3 not taken.
80568 if(NO_GRIDLOCK)
16803 {
16804 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16805 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16806 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16807 {
16808 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16809 sprite::move((zfix)-1,(zfix)0);
16810 }
16811 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16812 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16813 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16814 {
16815 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16816 sprite::move((zfix)1,(zfix)0);
16817 }
16818 else
16819 {
16820 pushing=push+1;
16821 }
16822 }
16823 80568 else pushing=push+1;
16824
16825
2/4
✓ Branch 0 taken 80568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80568 times.
✗ Branch 3 not taken.
80568 if(charging==0 && spins==0)
16826 {
16827 80568 dir=down;
16828 80568 }
16829
16830
5/8
✓ Branch 0 taken 78600 times.
✓ Branch 1 taken 1968 times.
✓ Branch 2 taken 78600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78600 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 78600 times.
80568 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16831 {
16832 78600 herostep();
16833 78600 }
16834
16835 80568 return;
16836 }
16837 23075 else goto LEFTRIGHT_OLDMOVE;
16838 }
16839
16840 4177 return;
16841 }
16842
16843 LEFTRIGHT_OLDMOVE:
16844
16845
7/8
✓ Branch 0 taken 1211438 times.
✓ Branch 1 taken 697986 times.
✓ Branch 2 taken 1176053 times.
✓ Branch 3 taken 35385 times.
✓ Branch 4 taken 44836 times.
✓ Branch 5 taken 1166602 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 44836 times.
1909424 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16846 {
16847 44836 return;
16848 }
16849
16850
2/2
✓ Branch 0 taken 278455 times.
✓ Branch 1 taken 1586133 times.
1864588 if(DrunkLeft())
16851 {
16852
11/14
✓ Branch 0 taken 4749 times.
✓ Branch 1 taken 273706 times.
✓ Branch 2 taken 4715 times.
✓ Branch 3 taken 34 times.
✓ Branch 4 taken 4444 times.
✓ Branch 5 taken 271 times.
✓ Branch 6 taken 4444 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4444 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4444 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 4442 times.
278455 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16853 {
16854
3/4
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4437 times.
4442 if(dir!=left && dir!=right)
16855 {
16856
4/4
✓ Branch 0 taken 3161 times.
✓ Branch 1 taken 1276 times.
✓ Branch 2 taken 1345 times.
✓ Branch 3 taken 1816 times.
4437 if(yoff>2&&yoff<6)
16857 {
16858 1816 moveOld2(dir);
16859 1816 }
16860
2/2
✓ Branch 0 taken 1345 times.
✓ Branch 1 taken 1276 times.
2621 else if(yoff>=6)
16861 {
16862 1345 moveOld2(down);
16863 1345 }
16864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1276 times.
1276 else if(yoff>=1)
16865 {
16866 1276 moveOld2(up);
16867 1276 }
16868 4437 }
16869 else
16870 {
16871
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(yoff>=4)
16872 {
16873 5 moveOld2(down);
16874 5 }
16875 else if(yoff<4)
16876 {
16877 moveOld2(up);
16878 }
16879 }
16880 4442 }
16881 else
16882 {
16883 548026 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16884 274013 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
16885
16886 274013 execute(info);
16887
16888
2/2
✓ Branch 0 taken 110607 times.
✓ Branch 1 taken 163406 times.
274013 if(!info.isUnwalkable())
16889 {
16890 163406 moveOld2(left);
16891 163406 return;
16892 }
16893
16894
4/4
✓ Branch 0 taken 105025 times.
✓ Branch 1 taken 5582 times.
✓ Branch 2 taken 6065 times.
✓ Branch 3 taken 98960 times.
110607 if(!DrunkUp() && !DrunkDown())
16895 {
16896
2/4
✓ Branch 0 taken 98960 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98960 times.
98960 if(NO_GRIDLOCK)
16897 {
16898 int32_t v1=bigHitbox?0:8;
16899 int32_t v2=bigHitbox?8:12;
16900
16901 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16902 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16903 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16904 {
16905 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16906 sprite::move((zfix)0,(zfix)-1);
16907 }
16908 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16909 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16910 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16911 {
16912 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16913 sprite::move((zfix)0,(zfix)1);
16914 }
16915 else
16916 {
16917 pushing=push+1;
16918 }
16919 }
16920 98960 else pushing=push+1;
16921
16922
3/4
✓ Branch 0 taken 98954 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98954 times.
98960 if(charging==0 && spins==0)
16923 {
16924 98954 dir=left;
16925 98954 }
16926
16927
5/8
✓ Branch 0 taken 95979 times.
✓ Branch 1 taken 2981 times.
✓ Branch 2 taken 95979 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 95979 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 95979 times.
98960 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16928 {
16929 95979 herostep();
16930 95979 }
16931
16932 98960 return;
16933 }
16934 }
16935
16936 16089 return;
16937 }
16938
16939
2/2
✓ Branch 0 taken 1287657 times.
✓ Branch 1 taken 298476 times.
1586133 if(DrunkRight())
16940 {
16941
10/14
✓ Branch 0 taken 4795 times.
✓ Branch 1 taken 293681 times.
✓ Branch 2 taken 4674 times.
✓ Branch 3 taken 121 times.
✓ Branch 4 taken 4569 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 4569 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4569 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4569 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 4569 times.
298476 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16942 {
16943
4/4
✓ Branch 0 taken 4566 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 4563 times.
4569 if(dir!=left && dir!=right)
16944 {
16945
4/4
✓ Branch 0 taken 3247 times.
✓ Branch 1 taken 1316 times.
✓ Branch 2 taken 1372 times.
✓ Branch 3 taken 1875 times.
4563 if(yoff>2&&yoff<6)
16946 {
16947 1875 moveOld2(dir);
16948 1875 }
16949
2/2
✓ Branch 0 taken 1372 times.
✓ Branch 1 taken 1316 times.
2688 else if(yoff>=6)
16950 {
16951 1372 moveOld2(down);
16952 1372 }
16953
1/2
✓ Branch 0 taken 1316 times.
✗ Branch 1 not taken.
1316 else if(yoff>=1)
16954 {
16955 1316 moveOld2(up);
16956 1316 }
16957 4563 }
16958 else
16959 {
16960
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 if(yoff>=4)
16961 {
16962 1 moveOld2(down);
16963 1 }
16964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(yoff<4)
16965 {
16966 5 moveOld2(up);
16967 5 }
16968 }
16969 4569 }
16970 else
16971 {
16972 587814 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
16973 293907 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
16974
16975 293907 execute(info);
16976
16977
2/2
✓ Branch 0 taken 118080 times.
✓ Branch 1 taken 175827 times.
293907 if(!info.isUnwalkable())
16978 {
16979 175827 moveOld2(right);
16980 175827 return;
16981 }
16982
16983
4/4
✓ Branch 0 taken 113333 times.
✓ Branch 1 taken 4747 times.
✓ Branch 2 taken 5143 times.
✓ Branch 3 taken 108190 times.
118080 if(!DrunkUp() && !DrunkDown())
16984 {
16985
2/4
✓ Branch 0 taken 108190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108190 times.
108190 if(NO_GRIDLOCK)
16986 {
16987 int32_t v1=bigHitbox?0:8;
16988 int32_t v2=bigHitbox?8:12;
16989
16990 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16991 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16992 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16993 {
16994 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16995 sprite::move((zfix)0,(zfix)-1);
16996 }
16997 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16998 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16999 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17000 {
17001 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
17002 sprite::move((zfix)0,(zfix)1);
17003 }
17004 else
17005 {
17006 pushing=push+1;
17007 }
17008 }
17009 108190 else pushing=push+1;
17010
17011
2/4
✓ Branch 0 taken 108190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108190 times.
108190 if(charging==0 && spins==0)
17012 {
17013 108190 dir=right;
17014 108190 }
17015
17016
5/8
✓ Branch 0 taken 107215 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 107215 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107215 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 107215 times.
108190 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17017 {
17018 107215 herostep();
17019 107215 }
17020
17021 108190 return;
17022 }
17023 }
17024 14459 }
17025 }
17026 6180506 }
17027
17028 bool HeroClass::scr_walkflag(int dx,int dy,int d2,int mx,int my,bool kb)
17029 {
17030 if(toogam) return false;
17031
17032 if(blockpath && dy<80) //Blocked top parts of rooms
17033 return true;
17034
17035 if(blockmoving && mblock2.hit(dx,dy,0,1,1,1))
17036 return true;
17037 //collide_object handled in scr_canmove
17038
17039 if(isdungeon() && currscr<128 && dy<32
17040 && ((x<=112||x>=128) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17041 && !get_bit(quest_rules,qr_FREEFORM))
17042 return false; //Old NES dungeon stuff
17043
17044 bool solid = _walkflag(dx,dy,1,SWITCHBLOCK_STATE);
17045
17046 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
17047 {
17048 if(mx>=112&&mx<120&&my<40&&my>=32)
17049 solid=true;
17050
17051 if(mx>=136&&mx<144&&my<40&&my>=32)
17052 solid=true;
17053 }
17054
17055 if(action==swimming || IsSideSwim())
17056 {
17057 if(!solid)
17058 {
17059 bool isthissolid = false;
17060 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17061 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
17062 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17063 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17064 isthissolid = true;
17065 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
17066
17067 int ls = 22;
17068 if((get_bit(quest_rules,qr_DROWN) && isSwimming()) || (!diagonalMovement) || get_bit(quest_rules,qr_NO_HOPPING))
17069 ls = 1;
17070 if(landswim < ls)
17071 {
17072 if(mx<0||my<0);
17073 else if(mx>248);
17074 else if(mx>240);
17075 else if(my>168);
17076 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
17077 else if(iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17078 solid = false;
17079 else
17080 solid = true;
17081 }
17082 }
17083 else
17084 {
17085 int32_t wtrx = iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my);
17086 int32_t wtrx8 = iswaterex(MAPCOMBO(mx+8,my), currmap, currscr, -1, mx+8,my);
17087
17088 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17089 solid = false;
17090 }
17091 }
17092 else if(ladderx+laddery) // ladder is being used
17093 {
17094 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(mx) : x;
17095 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(my) : y;
17096
17097 if(ladderdir==up)
17098 {
17099 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17100 {
17101 bool temp = false;
17102
17103 if(!(abs(lx-(ladderx+8))<=8))
17104 temp = true;
17105
17106 if(!(abs((lx+8)-(ladderx+8))<=8))
17107 temp=true;
17108
17109 if(!temp)
17110 {
17111 solid = false;
17112 }
17113 else if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17114 {
17115 solid = true;
17116 }
17117 }
17118 }
17119 else
17120 {
17121 if(abs(lx-(ladderx+8))<=8)
17122 {
17123 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17124 {
17125 solid = false;
17126 }
17127 else if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17128 {
17129 solid = true;
17130 }
17131 else if((abs(ly-laddery+8)<=8) && d2<=down)
17132 {
17133 solid = false;
17134 }
17135 }
17136 }
17137 }
17138 else if(solid || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
17139 {
17140 // see if it's a good spot for the ladder or for swimming
17141 bool unwalkablex = _walkflag(mx,my,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
17142 bool unwalkablex8 = _walkflag(mx+8,my,1,SWITCHBLOCK_STATE);
17143
17144 if(get_bit(quest_rules, qr_DROWN))
17145 {
17146 // Drowning changes the following attributes:
17147 // * Dangerous water is also walkable, so ignore the previous
17148 // definitions of unwalkablex and unwalkablex8.
17149 // * Instead, prevent the ladder from being used in the
17150 // one frame where Hero has landed on water before drowning.
17151 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
17152 }
17153
17154 // check if he can swim
17155 if(current_item(itype_flippers) && z==0 && fakez==0)
17156 {
17157 int32_t wtrx = iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my);
17158 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,my), currmap, currscr, -1, mx+8,my);
17159 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
17160 {
17161 //ladder ignores water combos that are now walkable thanks to flippers -DD
17162 unwalkablex = unwalkablex && (!wtrx);
17163 unwalkablex8 = unwalkablex8 && (!wtrx8);
17164
17165 if(landswim >= 22)
17166 {
17167 solid = false;
17168 }
17169 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17170 {
17171 if(dir==d2)
17172 {
17173 ladderx = 0;
17174 laddery = 0;
17175 }
17176 }
17177 }
17178 }
17179
17180 // check if he can use the ladder
17181 // "Allow Ladder Anywhere" is toggled by fLADDER
17182 if(can_deploy_ladder())
17183 // laddersetup
17184 {
17185 // Check if there's water to use the ladder over
17186 bool wtrx = (iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my) != 0);
17187 bool wtrx8 = (iswaterex(MAPCOMBO(mx+8,my), currmap, currscr, -1, mx+8,my) != 0);
17188 int32_t ldrid = current_item_id(itype_ladder);
17189 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
17190
17191 if(wtrx || wtrx8)
17192 {
17193 if(isSideViewHero())
17194 {
17195 wtrx = !_walkflag(mx, my+8, 1,SWITCHBLOCK_STATE) && !_walkflag(mx, my, 1,SWITCHBLOCK_STATE) && dir!=down;
17196 wtrx8 = !_walkflag(mx+8, my+8, 1,SWITCHBLOCK_STATE) && !_walkflag(mx+8, my, 1,SWITCHBLOCK_STATE) && dir!=down;
17197 }
17198 // * walk on half-water using the ladder instead of using flippers.
17199 // * otherwise, walk on ladder(+hookshot) combos.
17200 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(mx, my)) || isstepable(MAPCOMBO(mx+8,my)) || wtrx==true))
17201 {
17202 if(!get_bit(quest_rules, qr_OLD_210_WATER))
17203 {
17204 //if Hero could swim on a tile instead of using the ladder,
17205 //refuse to use the ladder to step over that tile. -DD
17206 wtrx = isstepable(MAPCOMBO(mx, my)) && unwalkablex;
17207 wtrx8 = isstepable(MAPCOMBO(mx+8,my)) && unwalkablex8;
17208 }
17209 }
17210 }
17211 else
17212 {
17213 // No water; check other things
17214
17215 //Check pits
17216 if(ladderpits)
17217 {
17218 int32_t pit_cmb = getpitfall(mx,my);
17219 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17220 pit_cmb = getpitfall(mx+8,my);
17221 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17222 }
17223 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
17224 {
17225 int32_t combo=combobuf[MAPCOMBO(mx, my)].type;
17226 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17227 combo=combobuf[MAPCOMBO(mx+8, my)].type;
17228 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17229 }
17230 }
17231
17232 for (int32_t i = 0; i <= 1; ++i)
17233 {
17234 if(tmpscr2[i].valid!=0)
17235 {
17236 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
17237 {
17238 if (combobuf[MAPCOMBO2(i,mx,my)].type == cBRIDGE && !_walkflag_layer(mx,my,1, &(tmpscr2[i]))) wtrx = false;
17239 if (combobuf[MAPCOMBO2(i,mx+8,my)].type == cBRIDGE && !_walkflag_layer(mx+8,my,1, &(tmpscr2[i]))) wtrx8 = false;
17240 }
17241 else
17242 {
17243 if (combobuf[MAPCOMBO2(i,mx,my)].type == cBRIDGE && _effectflag_layer(mx,my,1, &(tmpscr2[i]))) wtrx = false;
17244 if (combobuf[MAPCOMBO2(i,mx+8,my)].type == cBRIDGE && _effectflag_layer(mx+8,my,1, &(tmpscr2[i]))) wtrx8 = false;
17245 }
17246 }
17247 }
17248 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my));
17249
17250 if(d2==dir)
17251 {
17252 int32_t c = walkwater ? 0:8;
17253 int32_t b = walkwater ? 8:0;
17254
17255 if(d2>=left)
17256 {
17257 // If the difference between my and y is small enough
17258 if(abs((my)-(int32_t(y+c)))<=(b) && wtrx)
17259 {
17260 // Don't activate the ladder if it would be entirely
17261 // over water and Hero has the flippers. This isn't
17262 // a good way to do this, but it's too risky
17263 // to make big changes to this stuff.
17264 bool deployLadder=true;
17265 int32_t lx=mx&0xF0;
17266 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17267 {
17268 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
17269 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
17270 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
17271 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
17272 deployLadder=false;
17273 }
17274 if(deployLadder)
17275 {
17276 ladderx = mx&0xF0;
17277 laddery = y;
17278 ladderdir = left;
17279 ladderstart = d2;
17280 solid = laddery!=y.getInt();
17281 }
17282 }
17283 }
17284 else if(d2<=down)
17285 {
17286 // If the difference between mx and x is small enough
17287 if(abs((mx)-(int32_t(x+c)))<=(b) && wtrx)
17288 {
17289 ladderx = x;
17290 laddery = my&0xF0;
17291 ladderdir = up;
17292 ladderstart = d2;
17293 solid = ladderx!=x.getInt();
17294 }
17295 else if(abs((mx+8)-(int32_t(x+c)))<=(b) && wtrx8)
17296 {
17297 ladderx = x;
17298 laddery = my&0xF0;
17299 ladderdir = up;
17300 ladderstart = d2;
17301 solid = ladderx!=x.getInt();
17302 }
17303 }
17304 }
17305 }
17306 }
17307
17308 return solid;
17309 }
17310
17311 bool HeroClass::scr_canmove(zfix dx, zfix dy, bool kb, bool ign_sv)
17312 {
17313 if(toogam) return true;
17314 if(!(dx || dy)) return true;
17315 zfix bx = x, by = y+(bigHitbox?0:8); //left/top
17316 zfix rx = x+15, ry = y+15; //right/bottom
17317 zfix wid = 16, hei = bigHitbox ? 16 : 8;
17318 if(!ign_sv && dy < 0 && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17319 return false;
17320
17321 bool nosolid = true;
17322
17323 if(dx && !dy)
17324 {
17325 if(dx < 0)
17326 {
17327 int mx = (bx+dx).getFloor();
17328 for(zfix ty = 0; by+ty < ry; ty += 8)
17329 {
17330 if(scr_walkflag(mx, by+ty, left, mx, by, kb))
17331 return false;
17332 }
17333 if(scr_walkflag(mx, ry, left, mx, by, kb))
17334 return false;
17335 if(nosolid && collide_object(bx+dx,by,-dx,hei,this))
17336 return false;
17337 }
17338 else
17339 {
17340 int mx = (rx+dx).getCeil();
17341 int lx = mx-hit_width+1;
17342 for(zfix ty = 0; by+ty < ry; ty += 8)
17343 {
17344 if(scr_walkflag(mx, by+ty, right, lx, by, kb))
17345 return false;
17346 }
17347 if(scr_walkflag(mx, ry, right, lx, by, kb))
17348 return false;
17349 if(nosolid && collide_object(bx+wid,by,dx,hei,this))
17350 return false;
17351 }
17352 }
17353 else if(dy && !dx)
17354 {
17355 if(dy < 0)
17356 {
17357 int my = (by+dy).getFloor();
17358 for(zfix tx = 0; bx+tx < rx; tx += 8)
17359 {
17360 if(scr_walkflag(bx+tx, my, up, bx, my, kb))
17361 return false;
17362 }
17363 if(scr_walkflag(rx, my, up, bx, my, kb))
17364 return false;
17365 if(nosolid && collide_object(bx,by+dy,wid,-dy,this))
17366 return false;
17367 }
17368 else
17369 {
17370 int my = (ry+dy).getCeil();
17371 int ly = my-hit_height+1;
17372 for(zfix tx = 0; bx+tx < rx; tx += 8)
17373 {
17374 if(scr_walkflag(bx+tx, my, down, bx, ly, kb))
17375 return false;
17376 }
17377 if(scr_walkflag(rx, my, down, bx, ly, kb))
17378 return false;
17379 if(nosolid && collide_object(bx,by+hei,wid,dy,this))
17380 return false;
17381 }
17382 }
17383 else //! Untested, and currently unused.
17384 {
17385 return scr_canmove(dx, 0, kb, ign_sv) && scr_canmove(dy, 0, kb, ign_sv);
17386 }
17387 return true;
17388 }
17389 bool handle_movestate(std::function<bool()> proc)
17390 {
17391 zfix ox = Hero.x, oy = Hero.y;
17392 auto oladderx = Hero.ladderx;
17393 auto oladdery = Hero.laddery;
17394 auto oladderdir = Hero.ladderdir;
17395 auto oladderstart = Hero.ladderstart;
17396
17397 bool ret = proc();
17398
17399 Hero.x = ox;
17400 Hero.y = oy;
17401 Hero.ladderx = oladderx;
17402 Hero.laddery = oladdery;
17403 Hero.ladderdir = oladderdir;
17404 Hero.ladderstart = oladderstart;
17405
17406 return ret;
17407 }
17408 bool HeroClass::movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove, bool earlyret)
17409 {
17410 bool ret = true;
17411 bool sv = !ign_sv && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking;
17412 if(sv)
17413 dy = 0;
17414 if(dx && dy)
17415 shove = false;
17416 bool checkladder = dy < 0;
17417
17418 const int scl = 2;
17419 while(abs(dx) > scl || abs(dy) > scl)
17420 {
17421 if(abs(dx) > abs(dy))
17422 {
17423 int32_t tdx = dx.sign() * scl;
17424 if(movexy(tdx, 0, kb, ign_sv, shove, earlyret))
17425 dx -= tdx;
17426 else
17427 {
17428 if(earlyret) return false;
17429 dx = tdx;
17430 ret = false;
17431 }
17432 }
17433 else
17434 {
17435 int32_t tdy = dy.sign() * scl;
17436 if(movexy(0, tdy, kb, ign_sv, shove, earlyret))
17437 dy -= tdy;
17438 else
17439 {
17440 if(earlyret) return false;
17441 dy = tdy;
17442 ret = false;
17443 }
17444 }
17445 }
17446
17447 bool skipdmg = earlyret || hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS));
17448 if(dx)
17449 {
17450 if(scr_canmove(dx, 0, kb, ign_sv))
17451 x += dx;
17452 else
17453 {
17454 bool stopped = true;
17455 if(shove)
17456 {
17457 zfix tx = (dx < 0 ? (x-1) : (x+16));
17458 auto mdir = GET_XDIR(dx);
17459 int v1=bigHitbox?0:8;
17460 int v2=bigHitbox?8:12;
17461 bool hit_top = scr_walkflag(tx,y+v1,mdir,x+sign(dx),y,false);
17462 bool hit_mid = scr_walkflag(tx,y+v2,mdir,x+sign(dx),y,false);
17463 bool hit_bottom = scr_walkflag(tx,y+15,mdir,x+sign(dx),y,false);
17464 if(!hit_mid && (hit_top!=hit_bottom))
17465 {
17466 if(hit_bottom) //shove up
17467 {
17468 if(skipdmg || !checkdamagecombos(tx,y+15))
17469 y -= 1;
17470 }
17471 else //shove down
17472 {
17473 if(skipdmg || !checkdamagecombos(tx,y))
17474 y += 1;
17475 }
17476
17477 if(scr_canmove(dx, 0, kb, ign_sv))
17478 {
17479 x += dx;
17480 stopped = false;
17481 }
17482 }
17483 }
17484 if(stopped)
17485 {
17486 ret = false;
17487 int xsign = dx.sign();
17488 while(scr_canmove(xsign, 0, kb, ign_sv))
17489 {
17490 x += xsign;
17491 dx -= xsign;
17492 }
17493 if(dx)
17494 {
17495 dx.doDecBound(0,-9999, 0,9999);
17496 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
17497 if(scr_canmove(val, 0, kb, ign_sv))
17498 {
17499 retval = val;
17500 return BSEARCH_CONTINUE_AWAY0;
17501 }
17502 else return BSEARCH_CONTINUE_TOWARD0;
17503 });
17504 x += dx;
17505 }
17506 }
17507 }
17508 }
17509 if(dy)
17510 {
17511 if(scr_canmove(0, dy, kb, ign_sv))
17512 y += dy;
17513 else
17514 {
17515 bool stopped = true;
17516 if(shove)
17517 {
17518 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)-1) : (y+16));
17519 auto mdir = GET_YDIR(dy);
17520 bool hit_left = scr_walkflag(x,ty,mdir,x,y+sign(dy),false);
17521 bool hit_mid = scr_walkflag(x+8,ty,mdir,x,y+sign(dy),false);
17522 bool hit_right = scr_walkflag(x+15,ty,mdir,x,y+sign(dy),false);
17523 if(!hit_mid && (hit_left!=hit_right))
17524 {
17525 if(hit_right) //shove left
17526 {
17527 if(skipdmg || !checkdamagecombos(x+15,ty))
17528 x -= 1;
17529 }
17530 else //shove right
17531 {
17532 if(skipdmg || !checkdamagecombos(x,ty))
17533 x += 1;
17534 }
17535
17536 if(scr_canmove(0, dy, kb, ign_sv))
17537 {
17538 y += dy;
17539 stopped = false;
17540 }
17541 }
17542 }
17543 if(stopped)
17544 {
17545 if(earlyret) return false;
17546 ret = false;
17547 int ysign = dy.sign();
17548 while(scr_canmove(0, ysign, kb, ign_sv))
17549 {
17550 y += ysign;
17551 dy -= ysign;
17552 }
17553 if(dy)
17554 {
17555 dy.doDecBound(0,-9999, 0,9999);
17556 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
17557 if(scr_canmove(0, val, kb, ign_sv))
17558 {
17559 retval = val;
17560 return BSEARCH_CONTINUE_AWAY0;
17561 }
17562 else return BSEARCH_CONTINUE_TOWARD0;
17563 });
17564 y += dy;
17565 }
17566 }
17567 }
17568 }
17569
17570 if(earlyret)
17571 return ret;
17572 WalkflagInfo info;
17573 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
17574 execute(info);
17575 if(!ign_sv && sideview_mode() && IsSideSwim() && checkladder)
17576 {
17577 if(!iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)), currmap, currscr, -1, x, y+(bigHitbox?0:8) - 2, true, false)
17578 && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y+(bigHitbox?0:8) - 4) > 0)
17579 {
17580 if (game->get_sideswim_jump() != 0)
17581 {
17582 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
17583 sfx(WAV_ZN1SPLASH,(int32_t)x);
17584 hopclk = 0;
17585 if (charging || spins) action = attacking;
17586 else action = none;
17587 }
17588 else
17589 {
17590 movexy(0,-1*dy,false,false,false);
17591 }
17592 }
17593 }
17594 return ret;
17595 }
17596 bool HeroClass::can_movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove)
17597 {
17598 return handle_movestate([&]()
17599 {
17600 return movexy(dx,dy,kb,ign_sv,shove,true);
17601 });
17602 }
17603 bool HeroClass::moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
17604 {
17605 double v = degrees.getFloat() * PI / 180.0;
17606 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
17607 return movexy(dx, dy, kb, ign_sv, shove, earlyret);
17608 }
17609 bool HeroClass::can_moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove)
17610 {
17611 return handle_movestate([&]()
17612 {
17613 return moveAtAngle(degrees,px,kb,ign_sv,shove,true);
17614 });
17615 }
17616 bool HeroClass::moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
17617 {
17618 static const zfix diagrate = zslongToFix(7071);
17619 switch(NORMAL_DIR(dir))
17620 {
17621 case up:
17622 return movexy(0, -px, kb, ign_sv, shove, earlyret);
17623 case down:
17624 return movexy(0, px, kb, ign_sv, shove, earlyret);
17625 case left:
17626 return movexy(-px, 0, kb, ign_sv, shove, earlyret);
17627 case right:
17628 return movexy(px, 0, kb, ign_sv, shove, earlyret);
17629 case r_up:
17630 return movexy(px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
17631 case r_down:
17632 return movexy(px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
17633 case l_up:
17634 return movexy(-px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
17635 case l_down:
17636 return movexy(-px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
17637 }
17638 return false;
17639 }
17640 bool HeroClass::can_moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove)
17641 {
17642 return handle_movestate([&]()
17643 {
17644 return moveDir(dir,px,kb,ign_sv,shove,true);
17645 });
17646 }
17647
17648
17649 bool HeroClass::premove()
17650 {
17651 if(lstunclock) return false;
17652 if(is_conveyor_stunned) return (convey_forcex || convey_forcey);
17653 int32_t xoff=x.getInt()&7;
17654 int32_t yoff=y.getInt()&7;
17655 if(NO_GRIDLOCK)
17656 {
17657 xoff = 0;
17658 yoff = 0;
17659 }
17660 int32_t push=pushing;
17661 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
17662 int32_t flippers_id = current_item_id(itype_flippers);
17663 itemdata const& itm = itemsbuf[flippers_id];
17664 byte intbtn = byte(itm.misc3&0xFF);
17665 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
17666 bool eatdive = false;
17667 if(diveclk>0)
17668 {
17669 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
17670 --diveclk;
17671 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
17672 {
17673 diveclk = itemsbuf[flippers_id].misc2;
17674 eatdive = true;
17675 }
17676 }
17677 else if(action == swimming && dive_pressed)
17678 {
17679 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
17680 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
17681
17682 if(global_diving==screen_diving)
17683 {
17684 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
17685 eatdive = true;
17686 }
17687 }
17688 if(eatdive)
17689 getIntBtnInput(intbtn, true, true, false, false, false);
17690
17691 if(action==rafting)
17692 {
17693 do_rafting();
17694
17695 if(action==rafting)
17696 {
17697 return false;
17698 }
17699
17700
17701 set_respawn_point();
17702 trySideviewLadder();
17703 }
17704
17705 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
17706 int32_t btnwpn = -1;
17707
17708 //&0xFFF removes the "bow & arrows" bitmask
17709 //The Quick Sword is allowed to interrupt attacks.
17710 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
17711 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
17712 {
17713 if(DrunkrBbtn())
17714 {
17715 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
17716 dowpn = Bwpn&0xFFF;
17717 directWpn = directItemB;
17718 }
17719 else if(DrunkrAbtn())
17720 {
17721 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
17722 dowpn = Awpn&0xFFF;
17723 directWpn = directItemA;
17724 }
17725 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
17726 {
17727 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
17728 dowpn = Xwpn&0xFFF;
17729 directWpn = directItemX;
17730 }
17731 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
17732 {
17733 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
17734 dowpn = Ywpn&0xFFF;
17735 directWpn = directItemY;
17736 }
17737
17738 if(directWpn > 255) directWpn = 0;
17739
17740 // The Quick Sword only allows repeated sword or wand swings.
17741 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
17742 btnwpn=-1;
17743 }
17744
17745 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
17746 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
17747 {
17748 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
17749 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
17750 {
17751 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
17752 {
17753 paymagiccost(attackid,true);
17754 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
17755 }
17756 SetAttack();
17757 attack=wSword;
17758
17759 attackclk=0;
17760 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
17761
17762 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
17763 {
17764 if(!checkmagiccost(dowpn))
17765 {
17766 item_error();
17767 }
17768 else
17769 {
17770 //clear the item script stack for a new script
17771 int i = dowpn;
17772 FFCore.reset_script_engine_data(ScriptType::Item, i);
17773 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
17774 did_scripta=true;
17775 }
17776 }
17777 }
17778 else
17779 {
17780 item_error();
17781 }
17782 }
17783 else
17784 {
17785 did_scripta=false;
17786 }
17787
17788 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
17789 {
17790 if(DrunkUp() && canSideviewLadder())
17791 {
17792 setOnSideviewLadder(true);
17793 }
17794 else if(DrunkDown() && canSideviewLadder(true))
17795 {
17796 y+=1;
17797 setOnSideviewLadder(true);
17798 }
17799 }
17800
17801 int32_t wx=x;
17802 int32_t wy=y;
17803 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
17804 {
17805 if((xoff==0)||diagonalMovement)
17806 {
17807 if(DrunkUp()) dir=up;
17808 if(DrunkDown()) dir=down;
17809 }
17810
17811 if((yoff==0)||diagonalMovement)
17812 {
17813 if(DrunkLeft()) dir=left;
17814 if(DrunkRight()) dir=right;
17815 }
17816 }
17817
17818 switch(dir)
17819 {
17820 case up:
17821 wy-=16;
17822 break;
17823
17824 case down:
17825 wy+=16;
17826 break;
17827
17828 case left:
17829 wx-=16;
17830 break;
17831
17832 case right:
17833 wx+=16;
17834 break;
17835 }
17836
17837 do_lens();
17838
17839 bool no_jinx = true;
17840 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
17841 {
17842 bool paidmagic = false;
17843 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
17844 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
17845 {
17846 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
17847 no_jinx = checkitem_jinx(attackid);
17848 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
17849 {
17850 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
17851 paymagiccost(attackid,true);
17852 misc_internal_hero_flags |= LF_PAID_WAND_COST;
17853 }
17854 SetAttack();
17855 attack=wWand;
17856 attackclk=0;
17857 }
17858 else
17859 {
17860 item_error();
17861 }
17862 }
17863 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
17864 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
17865 {
17866 no_jinx = checkitem_jinx(dowpn);
17867 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
17868 {
17869 item_error();
17870 }
17871 else
17872 {
17873 paymagiccost(dowpn);
17874 paidmagic = true;
17875 SetAttack();
17876 attack=wHammer;
17877 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
17878 attackclk=0;
17879 }
17880 }
17881 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
17882 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
17883 {
17884 //checkbunny handled where magic cost is paid
17885 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
17886 no_jinx = checkitem_jinx(attackid);
17887 if(no_jinx)
17888 {
17889 SetAttack();
17890 attack=wFire;
17891 attackclk=0;
17892 }
17893 }
17894 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
17895 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
17896 {
17897 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
17898 no_jinx = checkitem_jinx(attackid);
17899 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
17900 {
17901 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
17902 paymagiccost(attackid,true);
17903 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
17904 }
17905 SetAttack();
17906 attack=wCByrna;
17907 attackclk=0;
17908 }
17909 else
17910 {
17911 item_error();
17912 }
17913 }
17914 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
17915 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
17916 {
17917 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
17918 no_jinx = checkitem_jinx(attackid);
17919 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
17920 {
17921 paymagiccost(attackid);
17922 SetAttack();
17923 attack = wBugNet;
17924 attackclk = 0;
17925 sfx(itemsbuf[attackid].usesound);
17926 }
17927 else
17928 {
17929 item_error();
17930 }
17931 }
17932 else
17933 {
17934 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
17935 no_jinx = checkitem_jinx(itmid);
17936 if(no_jinx)
17937 {
17938 paidmagic = startwpn(itmid);
17939
17940 if(paidmagic)
17941 {
17942 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
17943 {
17944 ;
17945 }
17946 else
17947 {
17948 SetAttack();
17949 attackclk=0;
17950 attack=none;
17951
17952 if(btnwpn==itype_brang)
17953 {
17954 attack=wBrang;
17955 }
17956 }
17957 }
17958 else
17959 {
17960 // Weapon not started: directWpn should be reset to prev. value.
17961 directWpn = olddirectwpn;
17962 }
17963 }
17964 }
17965
17966 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
17967 {
17968 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
17969 {
17970 item_error();
17971 }
17972 else
17973 {
17974 // Only charge for magic if item's magic cost wasn't already charged
17975 // for the item's main use.
17976 if(!paidmagic && attack!=wWand)
17977 paymagiccost(dowpn);
17978 //clear the item script stack for a new script
17979 int i = dowpn;
17980 FFCore.reset_script_engine_data(ScriptType::Item, i);
17981 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
17982 did_scriptb=true;
17983 }
17984 }
17985
17986 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
17987 {
17988 return false;
17989 }
17990 if(!no_jinx)
17991 did_scriptb = false;
17992 }
17993 else
17994 {
17995 did_scriptb=false;
17996 }
17997
17998 if(attackclk || action==attacking || action==sideswimattacking)
17999 {
18000
18001 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
18002 {
18003 if((xoff==0)||diagonalMovement)
18004 {
18005 if(DrunkUp()) dir=up;
18006 if(DrunkDown()) dir=down;
18007 }
18008
18009 if((yoff==0)||diagonalMovement)
18010 {
18011 if(DrunkLeft()) dir=left;
18012 if(DrunkRight()) dir=right;
18013 }
18014 }
18015
18016 bool attacked = doattack();
18017
18018 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
18019 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
18020 {
18021 if((xoff==0)||diagonalMovement)
18022 {
18023 if(DrunkUp()) dir=up;
18024
18025 if(DrunkDown()) dir=down;
18026 }
18027
18028 if((yoff==0)||diagonalMovement)
18029 {
18030 if(DrunkLeft()) dir=left;
18031
18032 if(DrunkRight()) dir=right;
18033 }
18034 }
18035
18036 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
18037 {
18038 return false;
18039 }
18040 else if(!attacked)
18041 {
18042 // Spin attack - change direction
18043 if(spins>1 && attack != wHammer)
18044 {
18045 spins--;
18046
18047 if(spins%5==0)
18048 {
18049 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
18050 sfx(itemsbuf[id].usesound,pan(x.getInt()));
18051 }
18052 attackclk=1;
18053
18054 switch(dir)
18055 {
18056 case up:
18057 dir=left;
18058 break;
18059
18060 case right:
18061 dir=up;
18062 break;
18063
18064 case down:
18065 dir=right;
18066 break;
18067
18068 case left:
18069 dir=down;
18070 break;
18071 }
18072
18073 return false;
18074 }
18075 else
18076 {
18077 spins=0;
18078 }
18079
18080 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
18081 else {action=none; FFCore.setHeroAction(none);}
18082 attackclk=0;
18083 charging=0;
18084 }
18085 }
18086 return true;
18087 }
18088 void HeroClass::movehero()
18089 {
18090 WalkflagInfo info;
18091 int32_t xoff=x.getInt()&7;
18092 int32_t yoff=y.getInt()&7;
18093 if(NO_GRIDLOCK)
18094 {
18095 xoff = 0;
18096 yoff = 0;
18097 }
18098 auto push=pushing;
18099 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
18100 pushing=0;
18101
18102 if(!is_conveyor_stunned) //these do not apply to conveyor auto-walk
18103 {
18104 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
18105 return;
18106
18107 if(action==walking) //still walking
18108 {
18109 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
18110 {
18111 if(attackclk>0) SetAttack();
18112 else {action = none; FFCore.setHeroAction(none);}
18113 hero_count=-1;
18114 return;
18115 }
18116
18117 autostep=false;
18118 } // endif (action==walking)
18119
18120 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
18121 {
18122 action=none; FFCore.setHeroAction(none);
18123 }
18124 }
18125
18126 bool nohorz = (isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam);
18127 bool novert = (isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam);
18128
18129 zfix dx, dy;
18130 if(is_conveyor_stunned)
18131 {
18132 dx = convey_forcex;
18133 dy = convey_forcey;
18134 convey_forcex = 0;
18135 convey_forcey = 0;
18136 if(action != walking)
18137 {
18138 action = walking; FFCore.setHeroAction(walking);
18139 }
18140 }
18141 else if(diagonalMovement)
18142 {
18143 switch(holddir)
18144 {
18145 case up:
18146 if(!Up())
18147 {
18148 holddir=-1;
18149 }
18150
18151 break;
18152
18153 case down:
18154 if(!Down())
18155 {
18156 holddir=-1;
18157 }
18158
18159 break;
18160
18161 case left:
18162 if(!Left())
18163 {
18164 holddir=-1;
18165 }
18166
18167 break;
18168
18169 case right:
18170 if(!Right())
18171 {
18172 holddir=-1;
18173 }
18174
18175 break;
18176
18177 default:
18178 break;
18179 } //end switch
18180
18181 if(DrunkUp()&&(holddir==-1||holddir==up)&&!novert)
18182 {
18183 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
18184 {
18185 dir=up;
18186 }
18187 holddir=up;
18188
18189 if(DrunkRight()&&shiftdir!=left&&!nohorz)
18190 {
18191 shiftdir=right;
18192 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
18193 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
18194 }
18195 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
18196 {
18197 shiftdir=left;
18198 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
18199 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
18200 }
18201 else
18202 {
18203 shiftdir=-1;
18204 }
18205 }
18206 else if(DrunkDown()&&(holddir==-1||holddir==down)&&!novert)
18207 {
18208 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
18209 {
18210 dir=down;
18211 }
18212 holddir=down;
18213
18214 if(DrunkRight()&&shiftdir!=left&&!nohorz)
18215 {
18216 shiftdir=right;
18217 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
18218 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
18219 }
18220 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
18221 {
18222 shiftdir=left;
18223 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
18224 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
18225 }
18226 else
18227 {
18228 shiftdir=-1;
18229 }
18230 }
18231 else if(DrunkLeft()&&(holddir==-1||holddir==left)&&!nohorz)
18232 {
18233 if(charging==0 && spins==0 && action != sideswimattacking)
18234 {
18235 dir=left;
18236 }
18237 sideswimdir = left;
18238 holddir=left;
18239
18240 if(DrunkUp()&&shiftdir!=down&&!novert)
18241 {
18242 shiftdir=up;
18243 }
18244 else if(DrunkDown()&&shiftdir!=up&&!novert)
18245 {
18246 shiftdir=down;
18247 }
18248 else
18249 {
18250 shiftdir=-1;
18251 }
18252 }
18253 else if(DrunkRight()&&(holddir==-1||holddir==right)&&!nohorz)
18254 {
18255 if(charging==0 && spins==0 && action != sideswimattacking)
18256 {
18257 dir=right;
18258 }
18259 sideswimdir = right;
18260 holddir=right;
18261
18262 if(DrunkUp()&&shiftdir!=down&&!novert)
18263 {
18264 shiftdir=up;
18265 }
18266 else if(DrunkDown()&&shiftdir!=up&&!novert)
18267 {
18268 shiftdir=down;
18269 }
18270 else
18271 {
18272 shiftdir=-1;
18273 }
18274 }
18275 else
18276 {
18277 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
18278 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
18279 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
18280 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
18281 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
18282
18283 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
18284 {
18285 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
18286 {
18287 //action=swimming;
18288 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
18289 {
18290 hopclk = 0xFF;
18291 }
18292 }
18293 }
18294 return;
18295 }
18296 get_move(holddir,dx,dy,dir);
18297 }
18298 else //4-way
18299 {
18300 shiftdir = -1;
18301 holddir = -1;
18302 if(!novert && DrunkUp())
18303 {
18304 holddir = dir = up;
18305 }
18306 else if(!novert && DrunkDown())
18307 {
18308 holddir = dir = down;
18309 }
18310 else if(!nohorz && DrunkLeft())
18311 {
18312 holddir = dir = left;
18313 }
18314 else if(!nohorz && DrunkRight())
18315 {
18316 holddir = dir = right;
18317 }
18318 get_move(holddir,dx,dy,dir);
18319 }
18320
18321 if(!new_engine_move(dx,dy))
18322 pushing = push+1;
18323 }
18324
18325 void HeroClass::get_move(int movedir, zfix& dx, zfix& dy, int32_t& facedir)
18326 {
18327 dx = 0; dy = 0;
18328 if(inlikelike || lstunclock > 0 || is_conveyor_stunned || movedir < 0)
18329 return;
18330
18331 zfix base_movepix(zfix(steprate) / 100);
18332 zfix movepix(base_movepix);
18333 zfix up_step(zfix(game->get_sideswim_up()) / 100);
18334 zfix left_step(zfix(game->get_sideswim_side()) / 100);
18335 zfix right_step(zfix(game->get_sideswim_side()) / 100);
18336 zfix down_step(zfix(game->get_sideswim_down()) / 100);
18337 std::vector<zfix*> steps;
18338 steps.push_back(&movepix);
18339 steps.push_back(&up_step);
18340 steps.push_back(&left_step);
18341 steps.push_back(&right_step);
18342 steps.push_back(&down_step);
18343
18344 mod_steps(steps);
18345
18346 up_step = -up_step;
18347 left_step = -left_step;
18348
18349
18350 zfix step(movepix);
18351 zfix step_diag(movepix);
18352
18353
18354 if (diagonalMovement)
18355 {
18356 //zprint2("Player's X is %d, Y is %d\n", x, y);
18357 if (((movedir == up || movedir == down) && (shiftdir == left || shiftdir == right)) ||
18358 (movedir == left || movedir == right) && (shiftdir == up || shiftdir == down))
18359 {
18360 step = STEP_DIAGONAL(step);
18361 up_step = STEP_DIAGONAL(up_step);
18362 left_step = STEP_DIAGONAL(left_step);
18363 right_step = STEP_DIAGONAL(right_step);
18364 down_step = STEP_DIAGONAL(down_step);
18365 }
18366 switch (movedir)
18367 {
18368 case up:
18369 switch (shiftdir)
18370 {
18371 case left:
18372 dx = IsSideSwim() ? left_step : -step;
18373 break;
18374 case right:
18375 dx = IsSideSwim() ? right_step : step;
18376 break;
18377 }
18378 if (IsSideSwim())
18379 {
18380 dy = up_step;
18381 }
18382 else dy = -step;
18383 break;
18384 case down:
18385 switch (shiftdir)
18386 {
18387 case left:
18388 dx = -step;
18389 if (IsSideSwim()) dx = left_step;
18390 break;
18391 case right:
18392 dx = step;
18393 if (IsSideSwim()) dx = right_step;
18394 break;
18395 }
18396 dy = IsSideSwim() ? down_step : step;
18397 break;
18398 case left:
18399 switch (shiftdir)
18400 {
18401 case up:
18402 if (IsSideSwim())
18403 {
18404 dy = up_step;
18405 }
18406 else dy = -step;
18407 break;
18408 case down:
18409 dy = step;
18410 if (IsSideSwim()) dy = down_step;
18411 break;
18412 }
18413 dx = IsSideSwim() ? left_step : -step;
18414 break;
18415 case right:
18416 switch (shiftdir)
18417 {
18418 case up:
18419 if (!IsSideSwim()) dy = -step;
18420 if (IsSideSwim())
18421 {
18422 dy = up_step;
18423 }
18424 break;
18425 case down:
18426 dy = step;
18427 if (IsSideSwim()) dy = down_step;
18428 break;
18429 }
18430 dx = IsSideSwim() ? right_step : step;
18431 break;
18432 };
18433 }
18434 else
18435 {
18436 switch (movedir)
18437 {
18438 case up:
18439 dy = IsSideSwim() ? up_step : -step;
18440 break;
18441 case down:
18442 dy = IsSideSwim() ? down_step : step;
18443 break;
18444 case left:
18445 dx = IsSideSwim() ? left_step : -step;
18446 break;
18447 case right:
18448 dx = IsSideSwim() ? right_step : step;
18449 break;
18450 };
18451 }
18452
18453 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (movedir == up || movedir == down))) //!DIRECTION SET
18454 {
18455 facedir = movedir;
18456 }
18457 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (movedir == up || movedir == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
18458 {
18459 facedir = shiftdir;
18460 }
18461 }
18462
18463 bool HeroClass::new_engine_move(zfix dx, zfix dy) //no collision check
18464 {
18465 if(!dx && !dy) return true;
18466 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
18467 {
18468 herostep();
18469
18470 //ack... don't walk if in midair! -DD
18471 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
18472 {
18473 action=walking; FFCore.setHeroAction(walking);
18474 }
18475
18476 if(++hero_count > (16*hero_animation_speed))
18477 hero_count=0;
18478 }
18479 else if(!(frame & 1))
18480 {
18481 herostep();
18482 }
18483
18484 bool ret = true;
18485 if(charging==0 || attack!=wHammer)
18486 {
18487 ret = movexy(dx,dy,false,false,true);
18488 }
18489 return ret;
18490 }
18491
18492 3356947 void HeroClass::moveOld(int32_t d2)
18493 {
18494 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
18495 static bool totalskip = false;
18496
18497
3/6
✓ Branch 0 taken 3356947 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3356947 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3356947 times.
3356947 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
18498 return;
18499
18500 3356947 int32_t dx=0,dy=0;
18501 3356947 int32_t xstep=lsteps[x.getInt()&7];
18502 3356947 int32_t ystep=lsteps[y.getInt()&7];
18503 3356947 int32_t z3skip=0;
18504 3356947 int32_t z3diagskip=0;
18505
3/6
✓ Branch 0 taken 77205 times.
✓ Branch 1 taken 3279742 times.
✓ Branch 2 taken 77205 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6636689 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
18506
5/6
✓ Branch 0 taken 149353 times.
✓ Branch 1 taken 3130389 times.
✓ Branch 2 taken 81755 times.
✓ Branch 3 taken 67598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 81755 times.
3279742 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
18507
2/2
✓ Branch 0 taken 3356361 times.
✓ Branch 1 taken 586 times.
3356947 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
18508 3356947 bool is_swimming = (action == swimming);
18509
18510 //slow walk combo, or charging, moves at 2/3 speed
18511 if(
18512
4/4
✓ Branch 0 taken 3310134 times.
✓ Branch 1 taken 46813 times.
✓ Branch 2 taken 77568 times.
✓ Branch 3 taken 3232566 times.
3403760 (!is_swimming && (slowcharging ^ slowcombo))||
18513
2/2
✓ Branch 0 taken 46813 times.
✓ Branch 1 taken 3232566 times.
3279379 (is_swimming && (zinit.hero_swim_speed>60))
18514 )
18515 {
18516 124381 totalskip = false;
18517
18518
2/2
✓ Branch 0 taken 5817 times.
✓ Branch 1 taken 118564 times.
124381 if(diagonalMovement)
18519 {
18520 5817 skipstep=(skipstep+1)%6;
18521
18522
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 2872 times.
5817 if(skipstep%2==0) z3skip=1;
18523 2945 else z3skip=0;
18524
18525
2/2
✓ Branch 0 taken 3919 times.
✓ Branch 1 taken 1898 times.
5817 if(skipstep%3==0) z3diagskip=1;
18526 3919 else z3diagskip=0;
18527 5817 }
18528 else
18529 {
18530
2/2
✓ Branch 0 taken 79518 times.
✓ Branch 1 taken 39046 times.
118564 if(d2<left)
18531 {
18532
2/2
✓ Branch 0 taken 48027 times.
✓ Branch 1 taken 31491 times.
79518 if(ystep>1)
18533 {
18534 31491 skipstep^=1;
18535 31491 ystep=skipstep;
18536 31491 }
18537 79518 }
18538 else
18539 {
18540
2/2
✓ Branch 0 taken 23745 times.
✓ Branch 1 taken 15301 times.
39046 if(xstep>1)
18541 {
18542 15301 skipstep^=1;
18543 15301 xstep=skipstep;
18544 15301 }
18545 }
18546 }
18547 124381 }
18548 // else if(is_swimming || (slowcharging && slowcombo))
18549 else if(
18550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3232566 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3232677 (is_swimming && (zinit.hero_swim_speed<60))||
18551
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 3232455 times.
3232566 (slowcharging && slowcombo)
18552 )
18553 {
18554 //swimming, or charging on a slow combo, moves at 1/2 speed
18555 111 totalskip = !totalskip;
18556
18557
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
18558 {
18559 skipstep=0;
18560 }
18561 111 }
18562 else
18563 {
18564 3232455 totalskip = false;
18565
18566
2/2
✓ Branch 0 taken 2921432 times.
✓ Branch 1 taken 311023 times.
3232455 if(diagonalMovement)
18567 {
18568 311023 skipstep=0;
18569 311023 }
18570 }
18571
18572
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 3356891 times.
3356947 if(!totalskip)
18573 {
18574
2/2
✓ Branch 0 taken 316840 times.
✓ Branch 1 taken 3040051 times.
3356891 if(diagonalMovement)
18575 {
18576
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 42924 times.
✓ Branch 2 taken 28497 times.
✓ Branch 3 taken 134155 times.
✓ Branch 4 taken 111264 times.
316840 switch(d2)
18577 {
18578 case up:
18579
2/2
✓ Branch 0 taken 3502 times.
✓ Branch 1 taken 39422 times.
42924 if(shiftdir==left)
18580 {
18581
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 1264 times.
3502 if(walkable)
18582 {
18583 2238 dy-=1-z3diagskip;
18584 2238 dx-=1-z3diagskip;
18585 2238 z3step=2;
18586 2238 }
18587 else
18588 {
18589 1264 dx-=1-z3diagskip;
18590 1264 z3step=2;
18591 }
18592 3502 }
18593
2/2
✓ Branch 0 taken 4597 times.
✓ Branch 1 taken 34825 times.
39422 else if(shiftdir==right)
18594 {
18595
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 1732 times.
4597 if(walkable)
18596 {
18597 2865 dy-=1-z3diagskip;
18598 2865 dx+=1-z3diagskip;
18599 2865 z3step=2;
18600 2865 }
18601 else
18602 {
18603 1732 dx+=1-z3diagskip;
18604 1732 z3step=2;
18605 }
18606 4597 }
18607 else
18608 {
18609
2/2
✓ Branch 0 taken 16422 times.
✓ Branch 1 taken 18403 times.
34825 if(walkable)
18610 {
18611 18403 dy-=z3step-z3skip;
18612 18403 z3step=(z3step%2)+1;
18613 18403 }
18614 }
18615
18616 42924 break;
18617
18618 case down:
18619
2/2
✓ Branch 0 taken 3039 times.
✓ Branch 1 taken 25458 times.
28497 if(shiftdir==left)
18620 {
18621
2/2
✓ Branch 0 taken 1696 times.
✓ Branch 1 taken 1343 times.
3039 if(walkable)
18622 {
18623 1696 dy+=1-z3diagskip;
18624 1696 dx-=1-z3diagskip;
18625 1696 z3step=2;
18626 1696 }
18627 else
18628 {
18629 1343 dx-=1-z3diagskip;
18630 1343 z3step=2;
18631 }
18632 3039 }
18633
2/2
✓ Branch 0 taken 3600 times.
✓ Branch 1 taken 21858 times.
25458 else if(shiftdir==right)
18634 {
18635
2/2
✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 1112 times.
3600 if(walkable)
18636 {
18637 2488 dy+=1-z3diagskip;
18638 2488 dx+=1-z3diagskip;
18639 2488 z3step=2;
18640 2488 }
18641 else
18642 {
18643 1112 dx+=1-z3diagskip;
18644 1112 z3step=2;
18645 }
18646 3600 }
18647 else
18648 {
18649
2/2
✓ Branch 0 taken 9004 times.
✓ Branch 1 taken 12854 times.
21858 if(walkable)
18650 {
18651 12854 dy+=z3step-z3skip;
18652 12854 z3step=(z3step%2)+1;
18653 12854 }
18654 }
18655
18656 28497 break;
18657
18658 case right:
18659
2/2
✓ Branch 0 taken 129352 times.
✓ Branch 1 taken 4803 times.
134155 if(shiftdir==up)
18660 {
18661
2/2
✓ Branch 0 taken 4409 times.
✓ Branch 1 taken 394 times.
4803 if(walkable)
18662 {
18663 4409 dy-=1-z3diagskip;
18664 4409 dx+=1-z3diagskip;
18665 4409 z3step=2;
18666 4409 }
18667 else
18668 {
18669 394 dy-=1-z3diagskip;
18670 394 z3step=2;
18671 }
18672 4803 }
18673
2/2
✓ Branch 0 taken 3813 times.
✓ Branch 1 taken 125539 times.
129352 else if(shiftdir==down)
18674 {
18675
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 450 times.
3813 if(walkable)
18676 {
18677 3363 dy+=1-z3diagskip;
18678 3363 dx+=1-z3diagskip;
18679 3363 z3step=2;
18680 3363 }
18681 else
18682 {
18683 450 dy+=1-z3diagskip;
18684 450 z3step=2;
18685 }
18686 3813 }
18687 else
18688 {
18689
2/2
✓ Branch 0 taken 13252 times.
✓ Branch 1 taken 112287 times.
125539 if(walkable)
18690 {
18691 112287 dx+=z3step-z3skip;
18692 112287 z3step=(z3step%2)+1;
18693 112287 }
18694 }
18695
18696 134155 break;
18697
18698 case left:
18699
2/2
✓ Branch 0 taken 107496 times.
✓ Branch 1 taken 3768 times.
111264 if(shiftdir==up)
18700 {
18701
2/2
✓ Branch 0 taken 3458 times.
✓ Branch 1 taken 310 times.
3768 if(walkable)
18702 {
18703 3458 dy-=1-z3diagskip;
18704 3458 dx-=1-z3diagskip;
18705 3458 z3step=2;
18706 3458 }
18707 else
18708 {
18709 310 dy-=1-z3diagskip;
18710 310 z3step=2;
18711 }
18712 3768 }
18713
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 104392 times.
107496 else if(shiftdir==down)
18714 {
18715
2/2
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 281 times.
3104 if(walkable)
18716 {
18717 2823 dy+=1-z3diagskip;
18718 2823 dx-=1-z3diagskip;
18719 2823 z3step=2;
18720 2823 }
18721 else
18722 {
18723 281 dy+=1-z3diagskip;
18724 281 z3step=2;
18725 }
18726 3104 }
18727 else
18728 {
18729
2/2
✓ Branch 0 taken 12264 times.
✓ Branch 1 taken 92128 times.
104392 if(walkable)
18730 {
18731 92128 dx-=z3step-z3skip;
18732 92128 z3step=(z3step%2)+1;
18733 92128 }
18734 }
18735
18736 111264 break;
18737 }
18738 316840 }
18739 else
18740 {
18741
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 711802 times.
✓ Branch 2 taken 581791 times.
✓ Branch 3 taken 840179 times.
✓ Branch 4 taken 906279 times.
3040051 switch(d2)
18742 {
18743 case up:
18744
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 711494 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
711802 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
18745
18746 711802 break;
18747
18748 case down:
18749
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 581737 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
581791 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
18750
18751 581791 break;
18752
18753 case left:
18754 840179 dx-=xstep;
18755 840179 break;
18756
18757 case right:
18758 906279 dx+=xstep;
18759 906279 break;
18760 }
18761 }
18762 3356891 }
18763
18764
8/16
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3356361 times.
✓ Branch 2 taken 3356082 times.
✓ Branch 3 taken 865 times.
✓ Branch 4 taken 3355886 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 3355886 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3355886 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3356947 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
18765 {
18766 3355886 dir=d2;
18767 3355886 }
18768
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1061 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1061 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
18769 {
18770 dir = shiftdir;
18771 }
18772
18773
3/4
✓ Branch 0 taken 3310134 times.
✓ Branch 1 taken 46813 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3310134 times.
3356947 if(action != swimming && !IsSideSwim())
18774 {
18775 3310134 herostep();
18776
18777 //ack... don't walk if in midair! -DD
18778
12/14
✓ Branch 0 taken 3309548 times.
✓ Branch 1 taken 586 times.
✓ Branch 2 taken 3309269 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 3309109 times.
✓ Branch 5 taken 160 times.
✓ Branch 6 taken 3309109 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 149353 times.
✓ Branch 9 taken 3159756 times.
✓ Branch 10 taken 81755 times.
✓ Branch 11 taken 67598 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 81755 times.
3310134 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
18779 {
18780 3227354 action=walking; FFCore.setHeroAction(walking);
18781 3227354 }
18782
18783
2/2
✓ Branch 0 taken 3135977 times.
✓ Branch 1 taken 174157 times.
3310134 if(++hero_count > (16*hero_animation_speed))
18784 174157 hero_count=0;
18785 3310134 }
18786
2/2
✓ Branch 0 taken 23410 times.
✓ Branch 1 taken 23403 times.
46813 else if(!(frame & 1))
18787 {
18788 23403 herostep();
18789 23403 }
18790
18791
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3356361 times.
✓ Branch 2 taken 586 times.
✗ Branch 3 not taken.
3356947 if(charging==0 || attack!=wHammer)
18792 {
18793 3356947 sprite::move((zfix)dx,(zfix)dy);
18794 3356947 }
18795 3356947 }
18796 3439945 void HeroClass::moveOld2(int32_t d2, int32_t forceRate)
18797 {
18798
4/6
✓ Branch 0 taken 3439630 times.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 3439630 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3439630 times.
3439945 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
18799 315 return;
18800
18801
3/4
✓ Branch 0 taken 3356947 times.
✓ Branch 1 taken 82683 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3356947 times.
3439630 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
18802 {
18803 3356947 moveOld(d2);
18804 3356947 return;
18805 }
18806
18807
4/8
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 79707 times.
✓ Branch 2 taken 2976 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2976 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
162390 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
18808
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 79707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79707 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
18809 //!DIMITODO: add QR for slow combos under hero
18810
4/4
✓ Branch 0 taken 79707 times.
✓ Branch 1 taken 2976 times.
✓ Branch 2 taken 2976 times.
✓ Branch 3 taken 5952 times.
88635 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
18811 {
18812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5952 times.
5952 if(tmpscr2[i].valid!=0)
18813 {
18814
1/2
✓ Branch 0 taken 5952 times.
✗ Branch 1 not taken.
5952 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18815 {
18816
2/4
✓ Branch 0 taken 5952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5952 times.
✗ Branch 3 not taken.
5952 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
18817 {
18818 slowcombo = false;
18819 break;
18820 }
18821 5952 }
18822 else
18823 {
18824 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
18825 {
18826 slowcombo = false;
18827 break;
18828 }
18829 }
18830 5952 }
18831 8928 }
18832
1/2
✓ Branch 0 taken 82683 times.
✗ Branch 1 not taken.
82683 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
18833 82683 bool is_swimming = (action == swimming);
18834 82683 bool fastSwim = (zinit.hero_swim_speed>60);
18835 82683 zfix rate(steprate);
18836 82683 int32_t shieldid = getCurrentActiveShield();
18837
1/2
✓ Branch 0 taken 82683 times.
✗ Branch 1 not taken.
82683 if(shieldid > -1)
18838 {
18839 itemdata const& shield = itemsbuf[shieldid];
18840 if(shield.flags & ITEM_FLAG10) //Change Speed flag
18841 {
18842 zfix perc = shield.misc7;
18843 perc /= 100;
18844 if(perc < 0)
18845 perc = (perc*-1)+1;
18846 rate = (rate * perc) + shield.misc8;
18847 }
18848 }
18849
18850 82683 zfix dx, dy;
18851 82683 zfix movepix(rate / 100);
18852 82683 zfix step(movepix);
18853 82683 zfix step_diag(movepix);
18854 82683 zfix up_step(game->get_sideswim_up() / -100.0);
18855 82683 zfix left_step(game->get_sideswim_side() / -100.0);
18856 82683 zfix right_step(game->get_sideswim_side() / 100.0);
18857 82683 zfix down_step(game->get_sideswim_down() / 100.0);
18858 82683 bool checkladder = false;
18859
18860
2/2
✓ Branch 0 taken 82682 times.
✓ Branch 1 taken 1 times.
82683 if(hero_newstep > movepix) hero_newstep = movepix;
18861
2/2
✓ Branch 0 taken 82682 times.
✓ Branch 1 taken 1 times.
82683 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
18862 //2/3 speed
18863
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 82683 times.
✓ Branch 2 taken 79707 times.
✓ Branch 3 taken 79707 times.
✓ Branch 4 taken 82683 times.
✓ Branch 5 taken 79707 times.
82683 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
18864 {
18865 162390 step = ((step / 3.0) * 2);
18866 162390 step_diag = ((step_diag / 3.0) * 2);
18867 162390 up_step = ((up_step / 3.0) * 2);
18868 162390 left_step = ((left_step / 3.0) * 2);
18869 162390 right_step = ((right_step / 3.0) * 2);
18870 162390 down_step = ((down_step / 3.0) * 2);
18871 162390 }
18872 //1/2 speed
18873
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 79707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 79707 times.
79707 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
18874 {
18875 step /= 2;
18876 step_diag /= 2;
18877 up_step /= 2;
18878 left_step /= 2;
18879 right_step /= 2;
18880 down_step /= 2;
18881 }
18882 //normal speed
18883 else
18884 {
18885 //no modification
18886 }
18887
18888
1/2
✓ Branch 0 taken 82683 times.
✗ Branch 1 not taken.
82683 if(diagonalMovement)
18889 {
18890 //zprint2("Player's X is %d, Y is %d\n", x, y);
18891
6/6
✓ Branch 0 taken 65361 times.
✓ Branch 1 taken 17322 times.
✓ Branch 2 taken 68734 times.
✓ Branch 3 taken 3373 times.
✓ Branch 4 taken 30201 times.
✓ Branch 5 taken 55855 times.
125950 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
18892
4/4
✓ Branch 0 taken 51412 times.
✓ Branch 1 taken 48039 times.
✓ Branch 2 taken 5684 times.
✓ Branch 3 taken 45748 times.
3373 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
18893 {
18894
2/4
✓ Branch 0 taken 17613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17613 times.
129323 if(hero_newstep > 0 && hero_newstep_diag > 0)
18895 {
18896 17613 step = STEP_DIAGONAL(step);
18897 17613 step_diag = STEP_DIAGONAL(step_diag);
18898 17613 up_step = STEP_DIAGONAL(up_step);
18899 17613 left_step = STEP_DIAGONAL(left_step);
18900 17613 right_step = STEP_DIAGONAL(right_step);
18901 17613 down_step = STEP_DIAGONAL(down_step);
18902 17613 }
18903 17613 }
18904
2/2
✓ Branch 0 taken 57005 times.
✓ Branch 1 taken 6356 times.
63361 if(hero_newstep < step) step = hero_newstep; //handle collision
18905
2/2
✓ Branch 0 taken 60757 times.
✓ Branch 1 taken 2604 times.
63361 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
18906
5/5
✓ Branch 0 taken 19322 times.
✓ Branch 1 taken 17322 times.
✓ Branch 2 taken 16841 times.
✓ Branch 3 taken 23443 times.
✓ Branch 4 taken 25077 times.
63361 switch(d2)
18907 {
18908 case up:
18909
3/3
✓ Branch 0 taken 13820 times.
✓ Branch 1 taken 1797 times.
✓ Branch 2 taken 1705 times.
17322 switch(shiftdir)
18910 {
18911 case left:
18912 1797 dx = -step_diag;
18913
1/2
✓ Branch 0 taken 1797 times.
✗ Branch 1 not taken.
1797 if (IsSideSwim()) dx = left_step;
18914 1797 break;
18915 case right:
18916 1705 dx = step_diag;
18917
1/2
✓ Branch 0 taken 1705 times.
✗ Branch 1 not taken.
1705 if (IsSideSwim()) dx = right_step;
18918 1705 break;
18919 }
18920
2/2
✓ Branch 0 taken 2367 times.
✓ Branch 1 taken 14955 times.
17322 if(walkable)
18921 {
18922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14955 times.
14955 if (!IsSideSwim()) dy = -step;
18923
1/2
✓ Branch 0 taken 14955 times.
✗ Branch 1 not taken.
14955 if (IsSideSwim())
18924 {
18925 dy = up_step;
18926 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
18927 }
18928 14955 }
18929 17322 break;
18930 case down:
18931
3/3
✓ Branch 0 taken 12515 times.
✓ Branch 1 taken 2165 times.
✓ Branch 2 taken 2161 times.
16841 switch(shiftdir)
18932 {
18933 case left:
18934 2165 dx = -step_diag;
18935
1/2
✓ Branch 0 taken 2165 times.
✗ Branch 1 not taken.
2165 if (IsSideSwim()) dx = left_step;
18936 2165 break;
18937 case right:
18938 2161 dx = step_diag;
18939
1/2
✓ Branch 0 taken 2161 times.
✗ Branch 1 not taken.
2161 if (IsSideSwim()) dx = right_step;
18940 2161 break;
18941 }
18942
2/2
✓ Branch 0 taken 1673 times.
✓ Branch 1 taken 15168 times.
16841 if(walkable)
18943 {
18944 15168 dy = step;
18945
1/2
✓ Branch 0 taken 15168 times.
✗ Branch 1 not taken.
15168 if (IsSideSwim()) dy = down_step;
18946 15168 }
18947 16841 break;
18948 case left:
18949
3/3
✓ Branch 0 taken 18533 times.
✓ Branch 1 taken 2719 times.
✓ Branch 2 taken 2191 times.
23443 switch(shiftdir)
18950 {
18951 case up:
18952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2719 times.
2719 if (!IsSideSwim()) dy = -step_diag;
18953
1/2
✓ Branch 0 taken 2719 times.
✗ Branch 1 not taken.
2719 if (IsSideSwim())
18954 {
18955 dy = up_step;
18956 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
18957 }
18958 2719 break;
18959 case down:
18960 2191 dy = step_diag;
18961
1/2
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
2191 if (IsSideSwim()) dy = down_step;
18962 2191 break;
18963 }
18964
2/2
✓ Branch 0 taken 2436 times.
✓ Branch 1 taken 21007 times.
23443 if(walkable)
18965 {
18966 21007 dx = -step;
18967
1/2
✓ Branch 0 taken 21007 times.
✗ Branch 1 not taken.
21007 if (IsSideSwim()) dx = left_step;
18968 21007 }
18969 23443 break;
18970 case right:
18971
3/3
✓ Branch 0 taken 20202 times.
✓ Branch 1 taken 2534 times.
✓ Branch 2 taken 2341 times.
25077 switch(shiftdir)
18972 {
18973 case up:
18974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2534 times.
2534 if (!IsSideSwim()) dy = -step_diag;
18975
1/2
✓ Branch 0 taken 2534 times.
✗ Branch 1 not taken.
2534 if (IsSideSwim())
18976 {
18977 dy = up_step;
18978 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
18979 }
18980 2534 break;
18981 case down:
18982 2341 dy = step_diag;
18983
1/2
✓ Branch 0 taken 2341 times.
✗ Branch 1 not taken.
2341 if (IsSideSwim()) dy = down_step;
18984 2341 break;
18985 }
18986
2/2
✓ Branch 0 taken 2433 times.
✓ Branch 1 taken 22644 times.
25077 if(walkable)
18987 {
18988 22644 dx = step;
18989
1/2
✓ Branch 0 taken 22644 times.
✗ Branch 1 not taken.
22644 if (IsSideSwim()) dx = right_step;
18990 22644 }
18991 25077 break;
18992 };
18993 102005 }
18994 else
18995 {
18996 if(hero_newstep < step) step = hero_newstep; //handle collision
18997 switch(d2)
18998 {
18999 case up:
19000 dy -= step;
19001 if (IsSideSwim()) dy = up_step;
19002 break;
19003 case down:
19004 dy += step;
19005 if (IsSideSwim()) dy = down_step;
19006 break;
19007 case left:
19008 dx -= step;
19009 if (IsSideSwim()) dx = left_step;
19010 break;
19011 case right:
19012 dx += step;
19013 if (IsSideSwim()) dx = right_step;
19014 break;
19015 };
19016 }
19017 102005 hero_newstep = movepix;
19018 102005 hero_newstep_diag = movepix;
19019
19020
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 102005 times.
✓ Branch 2 taken 82683 times.
✓ Branch 3 taken 19322 times.
✓ Branch 4 taken 82683 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82683 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 82683 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
102005 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
19021 {
19022 82683 dir=d2;
19023 82683 }
19024
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 19322 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
19322 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
19025 {
19026 dir = shiftdir;
19027 }
19028
2/2
✓ Branch 0 taken 101993 times.
✓ Branch 1 taken 12 times.
102005 if(forceRate > -1)
19029 {
19030 12 checkladder = false;
19031
1/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12 switch(dir)
19032 {
19033 case right:
19034 case r_up:
19035 case r_down:
19036 12 dx = zfix(forceRate) / 100;
19037 12 break;
19038 case left:
19039 case l_up:
19040 case l_down:
19041 dx = zfix(-forceRate) / 100;
19042 break;
19043 default:
19044 dx = 0;
19045 }
19046
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
12 switch(dir)
19047 {
19048 case down:
19049 case r_down:
19050 case l_down:
19051 dy = zfix(forceRate) / 100;
19052 break;
19053 case up:
19054 case r_up:
19055 case l_up:
19056 dy = zfix(-forceRate) / 100;
19057 break;
19058 default:
19059 12 dy = 0;
19060 12 }
19061 12 }
19062
4/4
✓ Branch 0 taken 31204 times.
✓ Branch 1 taken 70801 times.
✓ Branch 2 taken 24841 times.
✓ Branch 3 taken 6363 times.
102005 if(dx == 0 && dy == 0) return;
19063
5/8
✓ Branch 0 taken 76320 times.
✓ Branch 1 taken 19322 times.
✓ Branch 2 taken 76320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76320 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 76320 times.
95642 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
19064 {
19065 76320 herostep();
19066
19067 //ack... don't walk if in midair! -DD
19068
6/14
✓ Branch 0 taken 76320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75782 times.
✓ Branch 5 taken 538 times.
✓ Branch 6 taken 75782 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 75782 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
76320 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
19069 {
19070 75782 action=walking; FFCore.setHeroAction(walking);
19071 75782 }
19072
19073
2/2
✓ Branch 0 taken 72420 times.
✓ Branch 1 taken 3900 times.
76320 if(++hero_count > (16*hero_animation_speed))
19074 3900 hero_count=0;
19075 76320 }
19076
1/2
✓ Branch 0 taken 19322 times.
✗ Branch 1 not taken.
19322 else if(!(frame & 1))
19077 {
19078 herostep();
19079 }
19080
19081
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 95642 times.
✓ Branch 2 taken 19322 times.
✓ Branch 3 taken 19322 times.
95642 if(charging==0 || attack!=wHammer)
19082 {
19083 114964 sprite::move(dx, dy);
19084 114964 WalkflagInfo info;
19085 114964 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
19086 114964 execute(info);
19087
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 76320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 76320 times.
✗ Branch 7 not taken.
114964 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
19088 {
19089 if (game->get_sideswim_jump() != 0)
19090 {
19091 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
19092 sfx(WAV_ZN1SPLASH,(int32_t)x);
19093 hopclk = 0;
19094 if (charging || spins) action = attacking;
19095 else action = none;
19096 }
19097 else
19098 {
19099 sprite::move(zfix(0), zfix(-1*dy));
19100 }
19101 }
19102 76320 }
19103 3459267 }
19104
19105 15687881 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
19106 {
19107 15687881 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
19108 }
19109 15687881 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
19110 {
19111 15687881 WalkflagInfo ret;
19112
19113 15687881 wx = vbound(wx, -1, 256);
19114 15687881 wy = vbound(wy, -1, 176);
19115
19116
8/8
✓ Branch 0 taken 15619556 times.
✓ Branch 1 taken 68325 times.
✓ Branch 2 taken 15555310 times.
✓ Branch 3 taken 64246 times.
✓ Branch 4 taken 15555279 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 2475 times.
✓ Branch 7 taken 15552804 times.
15687881 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
19117 {
19118 135077 ret.setUnwalkable(false);
19119 135077 return ret;
19120 }
19121
19122
2/2
✓ Branch 0 taken 41482 times.
✓ Branch 1 taken 15511322 times.
15552804 if(toogam)
19123 {
19124 41482 ret.setUnwalkable(false);
19125 41482 return ret;
19126 }
19127
19128
4/4
✓ Branch 0 taken 319804 times.
✓ Branch 1 taken 15191518 times.
✓ Branch 2 taken 312628 times.
✓ Branch 3 taken 7176 times.
15511322 if(blockpath && wy<(bigHitbox?80:88))
19129 {
19130 7176 ret.setUnwalkable(true);
19131 7176 return ret;
19132 }
19133
19134
4/4
✓ Branch 0 taken 133900 times.
✓ Branch 1 taken 15370246 times.
✓ Branch 2 taken 101869 times.
✓ Branch 3 taken 32031 times.
15504146 if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
19135 {
19136 32031 ret.setUnwalkable(true);
19137 32031 return ret;
19138 }
19139
19140
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 15472105 times.
15472115 if (collide_object(wx, wy,1, 1))
19141 {
19142 10 ret.setUnwalkable(true);
19143 10 return ret;
19144 }
19145
19146
15/22
✓ Branch 0 taken 9040628 times.
✓ Branch 1 taken 6431477 times.
✓ Branch 2 taken 8719751 times.
✓ Branch 3 taken 320877 times.
✓ Branch 4 taken 8434522 times.
✓ Branch 5 taken 285229 times.
✓ Branch 6 taken 285229 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 285229 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 285229 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 145354 times.
✓ Branch 15 taken 139875 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 139875 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 139875 times.
✓ Branch 20 taken 23842 times.
✓ Branch 21 taken 15448263 times.
15636717 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
19147
2/2
✓ Branch 0 taken 19258 times.
✓ Branch 1 taken 120617 times.
285229 && !get_bit(quest_rules,qr_FREEFORM))
19148 {
19149 23842 ret.setUnwalkable(true);
19150 23842 return ret;
19151 }
19152
19153
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15448263 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15448263 times.
15448263 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
19154
19155
6/6
✓ Branch 0 taken 9016786 times.
✓ Branch 1 taken 6431477 times.
✓ Branch 2 taken 8695909 times.
✓ Branch 3 taken 320877 times.
✓ Branch 4 taken 2475524 times.
✓ Branch 5 taken 6220385 times.
15448263 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
19156 {
19157
3/6
✓ Branch 0 taken 6220385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6220385 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6220385 times.
6220385 if((diagonalMovement||NO_GRIDLOCK))
19158 {
19159 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
19160
19161 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
19162 }
19163 6220385 }
19164 //All problems related to exiting water are probably here. -Z
19165
3/4
✓ Branch 0 taken 15106330 times.
✓ Branch 1 taken 341933 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15106330 times.
15448263 if(action==swimming || IsSideSwim())
19166 {
19167
2/2
✓ Branch 0 taken 325082 times.
✓ Branch 1 taken 16851 times.
341933 if(!wf)
19168 {
19169 16851 bool isthissolid = false;
19170
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16851 times.
✓ Branch 2 taken 16851 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4526 times.
✓ Branch 5 taken 12325 times.
21377 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
19171
4/6
✓ Branch 0 taken 12325 times.
✓ Branch 1 taken 4526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4526 times.
✓ Branch 4 taken 4526 times.
✗ Branch 5 not taken.
16851 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
19172
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4526 times.
✓ Branch 4 taken 4526 times.
✗ Branch 5 not taken.
4526 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
19173
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4526 times.
✓ Branch 4 taken 4526 times.
✗ Branch 5 not taken.
16851 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
19174 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
19175
19176
19177
5/6
✓ Branch 0 taken 6945 times.
✓ Branch 1 taken 9906 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6945 times.
✓ Branch 4 taken 9438 times.
✓ Branch 5 taken 26275 times.
26757 if(landswim>= (get_bit(quest_rules,qr_DROWN) && isSwimming() ? 1
19178
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 9398 times.
9906 : (!diagonalMovement) ? 1 : (get_bit(quest_rules,qr_NO_HOPPING)?1:22)))
19179 {
19180 //Check for out of bounds for swimming
19181 9438 bool changehop = true;
19182
19183
5/6
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 8533 times.
✓ Branch 2 taken 905 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8526 times.
✓ Branch 5 taken 7621 times.
9438 if((diagonalMovement||NO_GRIDLOCK))
19184 {
19185
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
17059 if(wx<0||wy<0)
19186 changehop = false;
19187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 else if(wx>248)
19188 changehop = false;
19189
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 else if(wx>240&&cnt==2)
19190 changehop = false;
19191
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 else if(wy>168)
19192 changehop = false;
19193 7 }
19194
3/4
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 6716 times.
✓ Branch 2 taken 7628 times.
✗ Branch 3 not taken.
7628 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
19195 //This may be where the hang-up for exiting water exists. -Z
19196 // hop out of the water
19197
2/2
✓ Branch 0 taken 6716 times.
✓ Branch 1 taken 912 times.
7628 if(changehop)
19198 912 ret.setHopClk(1);
19199 7628 }
19200 else
19201 {
19202
6/6
✓ Branch 0 taken 11799 times.
✓ Branch 1 taken 14476 times.
✓ Branch 2 taken 13902 times.
✓ Branch 3 taken 12373 times.
✓ Branch 4 taken 8268 times.
✓ Branch 5 taken 5634 times.
26275 if((!(get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
19203 {
19204 //int32_t vx=((int32_t)x+4)&0xFFF8;
19205 //int32_t vy=((int32_t)y+4)&0xFFF8;
19206
2/2
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 3015 times.
13902 if(d2==left)
19207 {
19208
4/4
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 468 times.
✓ Branch 3 taken 83 times.
1019 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
19209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
468 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
19210
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 468 times.
468 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
19211
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
468 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
19212 {
19213 468 ret.setHopDir(d2);
19214 468 ret.setIlswim(true);
19215 468 }
19216 83 else ret.setIlswim(false);
19217 551 }
19218
2/2
✓ Branch 0 taken 2200 times.
✓ Branch 1 taken 815 times.
3015 else if(d2==right)
19219 {
19220
4/4
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 1598 times.
✓ Branch 2 taken 602 times.
✓ Branch 3 taken 1598 times.
2802 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
19221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 602 times.
602 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
19222
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 602 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 602 times.
602 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
19223
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 602 times.
602 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
19224 {
19225 602 ret.setHopDir(d2);
19226 602 ret.setIlswim(true);
19227 602 }
19228 1598 else ret.setIlswim(false);
19229 2200 }
19230
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 349 times.
815 else if(d2==up)
19231 {
19232
4/4
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 93 times.
607 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
19233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 258 times.
258 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
19234
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 258 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 256 times.
258 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
19235
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
19236 {
19237 256 ret.setHopDir(d2);
19238 256 ret.setIlswim(true);
19239 256 }
19240 93 else ret.setIlswim(false);
19241 349 }
19242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 else if(d2==down)
19243 {
19244
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 270 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 270 times.
662 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
19245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
19246
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 196 times.
196 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
19247
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
196 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
19248 {
19249 196 ret.setHopDir(d2);
19250 196 ret.setIlswim(true);
19251 196 }
19252 270 else ret.setIlswim(false);
19253 466 }
19254 3566 }
19255
19256
2/4
✓ Branch 0 taken 15939 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15939 times.
15939 if(wx<0||wy<0);
19257
2/2
✓ Branch 0 taken 2246 times.
✓ Branch 1 taken 13693 times.
15939 else if(wx>248);
19258
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13693 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13693 else if(wx>240&&cnt==2);
19259
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 13352 times.
13693 else if(wy>168);
19260
3/4
✓ Branch 0 taken 6106 times.
✓ Branch 1 taken 7246 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6106 times.
13352 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
19261 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
19262
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 7228 times.
7246 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
19263 {
19264 18 ret.setUnwalkable(false);
19265 18 return ret;
19266 }
19267 else
19268 {
19269 7228 ret.setUnwalkable(true);
19270 7228 return ret;
19271 }
19272 }
19273 16321 }
19274 else
19275 {
19276 325082 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
19277 325082 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
19278
19279
8/8
✓ Branch 0 taken 300985 times.
✓ Branch 1 taken 24097 times.
✓ Branch 2 taken 270393 times.
✓ Branch 3 taken 30592 times.
✓ Branch 4 taken 24097 times.
✓ Branch 5 taken 30592 times.
✓ Branch 6 taken 17008 times.
✓ Branch 7 taken 7089 times.
325082 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
19280 {
19281 287401 ret.setUnwalkable(false);
19282 287401 return ret;
19283 }
19284 }
19285 54002 }
19286
2/2
✓ Branch 0 taken 255754 times.
✓ Branch 1 taken 14850576 times.
15106330 else if(ladderx+laddery) // ladder is being used
19287 {
19288
7/10
✓ Branch 0 taken 6010 times.
✓ Branch 1 taken 249744 times.
✓ Branch 2 taken 5957 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
255754 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
19289
7/10
✓ Branch 0 taken 6010 times.
✓ Branch 1 taken 249744 times.
✓ Branch 2 taken 5957 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
255754 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
19290
19291
4/6
✓ Branch 0 taken 255605 times.
✓ Branch 1 taken 149 times.
✓ Branch 2 taken 255605 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 255605 times.
255754 if((diagonalMovement||NO_GRIDLOCK))
19292 {
19293
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(ladderdir==up)
19294 {
19295 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
19296 {
19297 bool temp = false;
19298
19299 if(!(abs(lx-(ladderx+8))<=8))
19300 temp = true;
19301
19302 if(cnt==2)
19303 if(!(abs((lx+8)-(ladderx+8))<=8))
19304 temp=true;
19305
19306 if(!temp)
19307 {
19308 ret.setUnwalkable(false);
19309 return ret;
19310 }
19311
19312 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
19313 {
19314 ret.setUnwalkable(true);
19315 return ret;
19316 }
19317 }
19318 }
19319 else
19320 {
19321
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 71 times.
149 if(abs(lx-(ladderx+8))<=8)
19322 {
19323
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 49 times.
71 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
19324 {
19325 22 ret.setUnwalkable(false);
19326 22 return ret;
19327 }
19328
19329
5/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
49 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
19330 {
19331 13 ret.setUnwalkable(true);
19332 13 return ret;
19333 }
19334
19335
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
36 if((abs(ly-laddery+8)<=8) && d2<=down)
19336 {
19337 ret.setUnwalkable(false);
19338 return ret;
19339 }
19340 36 }
19341 }
19342 114 } // diagonalMovement
19343 else
19344 {
19345
2/2
✓ Branch 0 taken 152207 times.
✓ Branch 1 taken 103398 times.
255605 if((d2&2)==ladderdir) // same direction
19346 {
19347
3/3
✓ Branch 0 taken 8984 times.
✓ Branch 1 taken 135045 times.
✓ Branch 2 taken 8178 times.
152207 switch(d2)
19348 {
19349 case up:
19350
2/2
✓ Branch 0 taken 5684 times.
✓ Branch 1 taken 2494 times.
8178 if(y.getInt()<=laddery)
19351 {
19352
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5684 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5684 times.
✓ Branch 4 taken 432 times.
✓ Branch 5 taken 5252 times.
10936 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
19353
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5252 times.
✓ Branch 2 taken 5252 times.
✗ Branch 3 not taken.
5252 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
19354 5684 return ret;
19355
19356 }
19357
19358 [[fallthrough]];
19359 case down:
19360
2/2
✓ Branch 0 taken 6138 times.
✓ Branch 1 taken 5340 times.
11478 if((wy&0xF0)==laddery)
19361 {
19362 6138 ret.setUnwalkable(false);
19363 6138 return ret;
19364 }
19365
19366 5340 break;
19367
19368 default:
19369
2/2
✓ Branch 0 taken 53843 times.
✓ Branch 1 taken 81202 times.
135045 if((wx&0xF0)==ladderx)
19370 {
19371 53843 ret.setUnwalkable(false);
19372 53843 return ret;
19373 }
19374 81202 }
19375
19376
2/2
✓ Branch 0 taken 5340 times.
✓ Branch 1 taken 81202 times.
86542 if(d2<=down)
19377 {
19378
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5340 times.
✓ Branch 2 taken 5340 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 593 times.
✓ Branch 5 taken 4747 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4747 times.
✓ Branch 8 taken 4747 times.
✗ Branch 9 not taken.
5340 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
19379 5340 return ret;
19380 }
19381
19382
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 81202 times.
✓ Branch 2 taken 81202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14606 times.
✓ Branch 5 taken 66596 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 66596 times.
✓ Branch 8 taken 66596 times.
✗ Branch 9 not taken.
81202 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
19383 81202 return ret;
19384 }
19385
19386 // different dir
19387
3/8
✓ Branch 0 taken 102969 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102969 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
103398 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
19388 {
19389 102969 ret.setUnwalkable(true);
19390 102969 return ret;
19391 }
19392
19393
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
19394 {
19395 20 ret.setUnwalkable(false);
19396 20 return ret;
19397 }
19398 }
19399 523 }
19400
6/6
✓ Branch 0 taken 12282081 times.
✓ Branch 1 taken 2568495 times.
✓ Branch 2 taken 11987131 times.
✓ Branch 3 taken 294950 times.
✓ Branch 4 taken 1451839 times.
✓ Branch 5 taken 10535292 times.
14850576 else if(wf || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
19401 {
19402 // see if it's a good spot for the ladder or for swimming
19403
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4315284 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4315284 times.
4315284 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
19404
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4315284 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4315284 times.
4315284 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
19405
19406
2/2
✓ Branch 0 taken 2264841 times.
✓ Branch 1 taken 2050443 times.
4315284 if(get_bit(quest_rules, qr_DROWN))
19407 {
19408 // Drowning changes the following attributes:
19409 // * Dangerous water is also walkable, so ignore the previous
19410 // definitions of unwalkablex and unwalkablex8.
19411 // * Instead, prevent the ladder from being used in the
19412 // one frame where Hero has landed on water before drowning.
19413 2264841 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
19414 2264841 }
19415
19416 // check if he can swim
19417
5/6
✓ Branch 0 taken 1330235 times.
✓ Branch 1 taken 2985049 times.
✓ Branch 2 taken 1330019 times.
✓ Branch 3 taken 216 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1330019 times.
4315284 if(current_item(itype_flippers) && z==0 && fakez==0)
19418 {
19419 1330019 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
19420 1330019 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
19421
2/6
✓ Branch 0 taken 1330019 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1330019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1330019 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
19422 {
19423 //ladder ignores water combos that are now walkable thanks to flippers -DD
19424
2/2
✓ Branch 0 taken 5037 times.
✓ Branch 1 taken 1324982 times.
1330019 unwalkablex = unwalkablex && (!wtrx);
19425
2/2
✓ Branch 0 taken 574392 times.
✓ Branch 1 taken 755627 times.
1330019 unwalkablex8 = unwalkablex8 && (!wtrx8);
19426
19427
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1330015 times.
1330019 if(landswim >= 22)
19428 {
19429 4 ret.setHopClk(2);
19430 4 ret.setUnwalkable(false);
19431 4 return ret;
19432 }
19433
8/8
✓ Branch 0 taken 1173940 times.
✓ Branch 1 taken 156075 times.
✓ Branch 2 taken 6535 times.
✓ Branch 3 taken 1167405 times.
✓ Branch 4 taken 156075 times.
✓ Branch 5 taken 1167405 times.
✓ Branch 6 taken 873 times.
✓ Branch 7 taken 155202 times.
1330015 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
19434 {
19435
4/6
✓ Branch 0 taken 5986 times.
✓ Branch 1 taken 1422 times.
✓ Branch 2 taken 5986 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5986 times.
7408 if(!(diagonalMovement||NO_GRIDLOCK))
19436 {
19437 5986 ret.setHopClk(2);
19438
19439
2/4
✓ Branch 0 taken 5986 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5986 times.
5986 if(charging || spins>5)
19440 {
19441 //if Hero is charging, he might be facing the wrong direction (we want him to
19442 //hop into the water, not in the facing direction)
19443 ret.setDir(d2);
19444 //moreover Hero can't charge in the water -DD
19445 ret.setChargeAttack();
19446 }
19447
19448 5986 ret.setUnwalkable(false);
19449 5986 return ret;
19450 }
19451
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 1245 times.
1422 else if(dir==d2)
19452 {
19453 1245 ret.setIlswim(true);
19454 1245 ladderx = 0;
19455 1245 laddery = 0;
19456 1245 }
19457 1422 }
19458 1324029 }
19459 1324029 }
19460
19461 // check if he can use the ladder
19462 // "Allow Ladder Anywhere" is toggled by fLADDER
19463
2/2
✓ Branch 0 taken 2980298 times.
✓ Branch 1 taken 1328996 times.
4309294 if(can_deploy_ladder())
19464 // laddersetup
19465 {
19466 // Check if there's water to use the ladder over
19467 1328996 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
19468 1328996 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
19469 1328996 int32_t ldrid = current_item_id(itype_ladder);
19470
1/2
✓ Branch 0 taken 1328996 times.
✗ Branch 1 not taken.
1328996 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
19471
19472
4/4
✓ Branch 0 taken 1321505 times.
✓ Branch 1 taken 7491 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 1321485 times.
1328996 if(wtrx || wtrx8)
19473 {
19474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7511 times.
7511 if(isSideViewHero())
19475 {
19476 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
19477 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
19478 }
19479 // * walk on half-water using the ladder instead of using flippers.
19480 // * otherwise, walk on ladder(+hookshot) combos.
19481
3/8
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 7085 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 426 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7511 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
19482 {
19483
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 387 times.
426 if(!get_bit(quest_rules, qr_OLD_210_WATER))
19484 {
19485 //if Hero could swim on a tile instead of using the ladder,
19486 //refuse to use the ladder to step over that tile. -DD
19487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
19488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
19489 387 }
19490 426 }
19491 7511 }
19492 else
19493 {
19494 // No water; check other things
19495
19496 //Check pits
19497
2/2
✓ Branch 0 taken 1320458 times.
✓ Branch 1 taken 1027 times.
1321485 if(ladderpits)
19498 {
19499 1027 int32_t pit_cmb = getpitfall(wx,wy);
19500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
19501 1027 pit_cmb = getpitfall(x+8,wy);
19502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
19503 1027 }
19504
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1320458 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
1321485 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
19505 {
19506 1321485 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
19507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1321485 times.
1321485 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
19508 1321485 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
19509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1321485 times.
1321485 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
19510 1321485 }
19511 }
19512
19513
2/2
✓ Branch 0 taken 2657992 times.
✓ Branch 1 taken 1328996 times.
3986988 for (int32_t i = 0; i <= 1; ++i)
19514 {
19515
2/2
✓ Branch 0 taken 2273662 times.
✓ Branch 1 taken 384330 times.
2657992 if(tmpscr2[i].valid!=0)
19516 {
19517
2/2
✓ Branch 0 taken 319092 times.
✓ Branch 1 taken 65238 times.
384330 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19518 {
19519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 319092 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
319092 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
19520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 319092 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
319092 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
19521 319092 }
19522 else
19523 {
19524
3/4
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 64979 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
65238 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
19525
3/4
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 65001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 237 times.
65238 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
19526 }
19527 384330 }
19528 2657992 }
19529
2/2
✓ Branch 0 taken 180430 times.
✓ Branch 1 taken 1148566 times.
1328996 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
19530
19531
4/6
✓ Branch 0 taken 1288526 times.
✓ Branch 1 taken 40470 times.
✓ Branch 2 taken 1288526 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1288526 times.
1328996 if((diagonalMovement||NO_GRIDLOCK))
19532 {
19533
2/2
✓ Branch 0 taken 11725 times.
✓ Branch 1 taken 28745 times.
40470 if(d2==dir)
19534 {
19535 28745 int32_t c = walkwater ? 0:8;
19536 28745 int32_t b = walkwater ? 8:0;
19537
19538
2/2
✓ Branch 0 taken 21217 times.
✓ Branch 1 taken 7528 times.
28745 if(d2>=left)
19539 {
19540 // If the difference between wy and y is small enough
19541
4/4
✓ Branch 0 taken 6210 times.
✓ Branch 1 taken 15007 times.
✓ Branch 2 taken 21214 times.
✓ Branch 3 taken 3 times.
21217 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
19542 {
19543 // Don't activate the ladder if it would be entirely
19544 // over water and Hero has the flippers. This isn't
19545 // a good way to do this, but it's too risky
19546 // to make big changes to this stuff.
19547 3 bool deployLadder=true;
19548 3 int32_t lx=wx&0xF0;
19549
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
3 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
19550 {
19551
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
19552 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
19553 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
19554 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
19555 deployLadder=false;
19556 2 }
19557
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(deployLadder)
19558 {
19559 3 ladderx = wx&0xF0;
19560 3 laddery = y;
19561 3 ladderdir = left;
19562 3 ladderstart = d2;
19563 3 ret.setUnwalkable(laddery!=y.getInt());
19564 3 return ret;
19565 }
19566 }
19567 21214 }
19568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7528 times.
7528 else if(d2<=down)
19569 {
19570 // If the difference between wx and x is small enough
19571
3/4
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 4705 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7528 times.
7528 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
19572 {
19573 ladderx = x;
19574 laddery = wy&0xF0;
19575 ladderdir = up;
19576 ladderstart = d2;
19577 ret.setUnwalkable(ladderx!=x.getInt());
19578 return ret;
19579 }
19580
19581
2/2
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 4705 times.
7528 if(cnt==2)
19582 {
19583
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4705 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4705 times.
4705 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
19584 {
19585 ladderx = x;
19586 laddery = wy&0xF0;
19587 ladderdir = up;
19588 ladderstart = d2;
19589 ret.setUnwalkable(ladderx!=x.getInt());
19590 return ret;
19591 }
19592 4705 }
19593 7528 }
19594 28742 }
19595 40467 }
19596 else
19597 {
19598
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1288526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1288526 times.
✓ Branch 4 taken 110191 times.
✓ Branch 5 taken 1178335 times.
1288526 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
19599
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1288526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1288526 times.
✓ Branch 4 taken 1205515 times.
✓ Branch 5 taken 83011 times.
1288526 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
19600
19601
2/2
✓ Branch 0 taken 1188054 times.
✓ Branch 1 taken 100472 times.
1288562 if((d2>=left && wtrx)
19602 // Deploy the ladder vertically even if Hero is only half on water.
19603
8/8
✓ Branch 0 taken 12556 times.
✓ Branch 1 taken 1175498 times.
✓ Branch 2 taken 100472 times.
✓ Branch 3 taken 1175498 times.
✓ Branch 4 taken 822 times.
✓ Branch 5 taken 99650 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 100436 times.
1288526 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
19604 {
19605
4/4
✓ Branch 0 taken 12202 times.
✓ Branch 1 taken 354 times.
✓ Branch 2 taken 501 times.
✓ Branch 3 taken 11701 times.
12556 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
19606 855 ladderdir = up;
19607 else
19608 11701 ladderdir = left;
19609
19610
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 11701 times.
12556 if(ladderdir==up)
19611 {
19612 855 ladderx = x.getInt()&0xF8;
19613 855 laddery = wy&0xF0;
19614 855 }
19615 else
19616 {
19617 11701 ladderx = wx&0xF0;
19618 11701 laddery = y.getInt()&0xF8;
19619 }
19620
19621 12556 ret.setUnwalkable(false);
19622 12556 return ret;
19623 }
19624 }
19625 1316437 }
19626 4296735 }
19627
19628 14886552 ret.setUnwalkable(wf);
19629 14886552 return ret;
19630 15694597 }
19631
19632 // Only checks for moving blocks. Apparently this is a thing we need.
19633 1484562 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
19634 {
19635 1484562 HeroClass::WalkflagInfo ret;
19636
2/2
✓ Branch 0 taken 15089 times.
✓ Branch 1 taken 1469473 times.
1484562 if (!blockmoving) //Without this, weird swimming behaviors happen.
19637 {
19638 1469473 ret.setFlags(~1);
19639 1469473 ret.setHopDir(-1);
19640 1469473 }
19641
2/2
✓ Branch 0 taken 2636 times.
✓ Branch 1 taken 1481926 times.
1484562 if(toogam) return ret;
19642
2/2
✓ Branch 0 taken 1466837 times.
✓ Branch 1 taken 15089 times.
1481926 if (blockmoving)
19643 15089 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
19644
1/2
✓ Branch 0 taken 1481926 times.
✗ Branch 1 not taken.
1481926 if (collide_object(wx, wy,1, 1))
19645 ret.setUnwalkable(true);
19646 1481926 return ret;
19647 1484562 }
19648
19649 6253981 bool HeroClass::checksoliddamage()
19650 {
19651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6253981 times.
6253981 if(toogam) return false;
19652
19653
2/4
✓ Branch 0 taken 6253981 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6253981 times.
6253981 if(z!=0||fakez!=0) return false;
19654 6253981 int32_t bx = x.getInt();
19655 6253981 int32_t by = y.getInt();
19656 6253981 int32_t initk = 0;
19657
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1509545 times.
✓ Branch 2 taken 1220024 times.
✓ Branch 3 taken 1692337 times.
✓ Branch 4 taken 1832075 times.
6253981 switch(dir)
19658 {
19659 case up:
19660
19661 1509545 by-=bigHitbox ? 4 : -4;
19662
19663
2/2
✓ Branch 0 taken 1509493 times.
✓ Branch 1 taken 52 times.
1509545 if(by<0)
19664 {
19665 52 return false;
19666 }
19667 1509493 break;
19668
19669 case down:
19670
19671 1220024 by+=20;
19672
2/2
✓ Branch 0 taken 11063 times.
✓ Branch 1 taken 1208961 times.
1220024 if(by>175)
19673 {
19674 11063 return false;
19675 }
19676
19677 1208961 break;
19678
19679 case left:
19680 1692337 bx-=4;
19681
2/2
✓ Branch 0 taken 9483 times.
✓ Branch 1 taken 1682854 times.
1692337 if (!bigHitbox)
19682 {
19683 1682854 by+=8;
19684 1682854 initk = 1;
19685 1682854 }
19686
2/2
✓ Branch 0 taken 1683500 times.
✓ Branch 1 taken 8837 times.
1692337 if(bx<0)
19687 {
19688 8837 return false;
19689 }
19690
19691 1683500 break;
19692
19693 case right:
19694
19695 1832075 bx+=20;
19696
2/2
✓ Branch 0 taken 13038 times.
✓ Branch 1 taken 1819037 times.
1832075 if (!bigHitbox)
19697 {
19698 1819037 by+=8;
19699 1819037 initk = 1;
19700 1819037 }
19701
2/2
✓ Branch 0 taken 13058 times.
✓ Branch 1 taken 1819017 times.
1832075 if(bx>255)
19702 {
19703 13058 return false;
19704 }
19705
19706 1819017 break;
19707 }
19708 6220971 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
19709 6220971 int32_t t = cmb.type;
19710
2/2
✓ Branch 0 taken 6220855 times.
✓ Branch 1 taken 116 times.
6220971 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19711 116 t = cNONE;
19712 6220971 int32_t initbx = bx;
19713 6220971 int32_t initby = by;
19714
19715 // Unlike push blocks, damage combos should be tested on layers 2 and under
19716
2/2
✓ Branch 0 taken 10233369 times.
✓ Branch 1 taken 6220958 times.
16454327 for(int32_t i=(get_bit(quest_rules,qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
19717 {
19718 10233369 bx = initbx;
19719 10233369 by = initby;
19720
2/2
✓ Branch 0 taken 24937521 times.
✓ Branch 1 taken 10233356 times.
35170877 for (int32_t k = initk; k <= 2; k++)
19721 {
19722 24937521 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
19723 24937521 t = cmb.type;
19724
2/2
✓ Branch 0 taken 24937195 times.
✓ Branch 1 taken 326 times.
24937521 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19725 326 t = cNONE;
19726 // Solid damage combos use pushing>0, hence the code is here.
19727
9/10
✓ Branch 0 taken 320455 times.
✓ Branch 1 taken 24617066 times.
✓ Branch 2 taken 64732 times.
✓ Branch 3 taken 255723 times.
✓ Branch 4 taken 61843 times.
✓ Branch 5 taken 2889 times.
✓ Branch 6 taken 729 times.
✓ Branch 7 taken 61114 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 729 times.
24937521 if (!get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
19728 {
19729
14/18
✓ Branch 0 taken 24922812 times.
✓ Branch 1 taken 11091 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11091 times.
✓ Branch 4 taken 11091 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1294 times.
✓ Branch 7 taken 9797 times.
✓ Branch 8 taken 253 times.
✓ Branch 9 taken 1041 times.
✓ Branch 10 taken 160 times.
✓ Branch 11 taken 93 times.
✓ Branch 12 taken 160 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 160 times.
✓ Branch 16 taken 24933843 times.
✓ Branch 17 taken 60 times.
24933903 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting && !get_bit(quest_rules, qr_NOSOLIDDAMAGECOMBOS))
19730 {
19731 // Bite Hero
19732
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 6 times.
60 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
19733 54 }
19734 24933897 }
19735
3/4
✓ Branch 0 taken 791708 times.
✓ Branch 1 taken 24145807 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 730622 times.
25668137 if(isSideViewHero() && // Check for sideview damage combos
19736
3/4
✓ Branch 0 taken 730622 times.
✓ Branch 1 taken 61086 times.
✓ Branch 2 taken 730622 times.
✗ Branch 3 not taken.
791708 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
19737 {
19738
2/2
✓ Branch 0 taken 60148 times.
✓ Branch 1 taken 670474 times.
730622 if (get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES))
19739 {
19740
2/6
✓ Branch 0 taken 60148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60148 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
60148 if (on_sideview_solid_oldpos(x,y,old_x,old_y) && (!getOnSideviewLadder() || DrunkDown()))
19741 {
19742
4/4
✓ Branch 0 taken 60142 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 60146 times.
✓ Branch 3 taken 2 times.
60148 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
19743 {
19744
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
19745 }
19746 60146 }
19747
1/2
✓ Branch 0 taken 60146 times.
✗ Branch 1 not taken.
60146 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
19748 60146 }
19749 else
19750 {
19751 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
19752
1/2
✓ Branch 0 taken 670474 times.
✗ Branch 1 not taken.
670474 if ( get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES ) )
19753 {
19754
2/2
✓ Branch 0 taken 670469 times.
✓ Branch 1 taken 5 times.
1340948 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
19755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
670474 x+8+(zc_max(tmpscr->csensitive-1,0)),
19756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
670474 y+17-(get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
19757
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 670474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
670474 y+17+zc_max((get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
19758 5 return true;
19759 670469 }
19760 else //2.50.1 and later
19761 {
19762 if(checkdamagecombos(x+4, x+12, y+16, y+24))
19763 return true;
19764 }
19765 }
19766
19767 730615 }
19768
2/2
✓ Branch 0 taken 13211121 times.
✓ Branch 1 taken 11726387 times.
24937508 if (dir < left) bx += (k % 2) ? 7 : 8;
19769 11726387 else by += (k % 2) ? 7 : 8;
19770 24937508 }
19771 10233356 }
19772 6220958 return false;
19773 6253981 }
19774 6395885 void HeroClass::checkpushblock()
19775 {
19776
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6382479 times.
6395885 if(toogam) return;
19777
19778
3/4
✓ Branch 0 taken 6378570 times.
✓ Branch 1 taken 3909 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6378570 times.
6382479 if(z!=0||fakez!=0) return;
19779
19780 // Return early in some cases..
19781 6378570 bool earlyReturn=false;
19782
19783
5/6
✓ Branch 0 taken 5682239 times.
✓ Branch 1 taken 696331 times.
✓ Branch 2 taken 5682239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5911761 times.
✓ Branch 5 taken 466809 times.
6378570 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
19784
2/2
✓ Branch 0 taken 2220202 times.
✓ Branch 1 taken 3691559 times.
5911761 if(x.getInt()&15) earlyReturn=true;
19785
19786 // if(y<16) return;
19787
4/4
✓ Branch 0 taken 250686 times.
✓ Branch 1 taken 6127884 times.
✓ Branch 2 taken 126097 times.
✓ Branch 3 taken 124589 times.
6378570 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)) return;
19788
19789 6253981 int32_t bx = x.getInt()&0xF0;
19790 6253981 int32_t by = (y.getInt()&0xF0);
19791
19792
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1509545 times.
✓ Branch 2 taken 1220024 times.
✓ Branch 3 taken 1692337 times.
✓ Branch 4 taken 1832075 times.
6253981 switch(dir)
19793 {
19794 case up:
19795
2/2
✓ Branch 0 taken 50366 times.
✓ Branch 1 taken 1459179 times.
1509545 if(y<16)
19796 {
19797 50366 earlyReturn=true;
19798 50366 break;
19799 }
19800
19801
3/4
✓ Branch 0 taken 267150 times.
✓ Branch 1 taken 1192029 times.
✓ Branch 2 taken 267150 times.
✗ Branch 3 not taken.
1459179 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
19802
19803
2/2
✓ Branch 0 taken 833871 times.
✓ Branch 1 taken 625308 times.
1459179 if((int32_t)x&8) bx+=16;
19804
19805 1459179 break;
19806
19807 case down:
19808
2/2
✓ Branch 0 taken 80724 times.
✓ Branch 1 taken 1139300 times.
1220024 if(y>128)
19809 {
19810 80724 earlyReturn=true;
19811 80724 break;
19812 }
19813 else
19814 {
19815 1139300 by+=16;
19816
19817
2/2
✓ Branch 0 taken 718850 times.
✓ Branch 1 taken 420450 times.
1139300 if((int32_t)x&8) bx+=16;
19818 }
19819
19820 1139300 break;
19821
19822 case left:
19823
2/2
✓ Branch 0 taken 84732 times.
✓ Branch 1 taken 1607605 times.
1692337 if(x<32)
19824 {
19825 84732 earlyReturn=true;
19826 84732 break;
19827 }
19828 else
19829 {
19830 1607605 bx-=16;
19831
19832
2/2
✓ Branch 0 taken 1026663 times.
✓ Branch 1 taken 580942 times.
1607605 if(y.getInt()&8)
19833 {
19834 580942 by+=16;
19835 580942 }
19836 }
19837
19838 1607605 break;
19839
19840 case right:
19841
2/2
✓ Branch 0 taken 88374 times.
✓ Branch 1 taken 1743701 times.
1832075 if(x>208)
19842 {
19843 88374 earlyReturn=true;
19844 88374 break;
19845 }
19846 else
19847 {
19848 1743701 bx+=16;
19849
19850
2/2
✓ Branch 0 taken 1133050 times.
✓ Branch 1 taken 610651 times.
1743701 if(y.getInt()&8)
19851 {
19852 610651 by+=16;
19853 610651 }
19854 }
19855
19856 1743701 break;
19857 }
19858
19859
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 6253968 times.
6253981 if (checksoliddamage()) return;
19860
19861
2/2
✓ Branch 0 taken 3756819 times.
✓ Branch 1 taken 2497149 times.
6253968 if(earlyReturn)
19862 3756819 return;
19863
19864 2497149 int itemid=current_item_id(itype_bracelet);
19865 2497149 size_t combopos = (by&0xF0)+(bx>>4);
19866
2/2
✓ Branch 0 taken 946275 times.
✓ Branch 1 taken 1550874 times.
2497149 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
19867
2/2
✓ Branch 0 taken 1550874 times.
✓ Branch 1 taken 946275 times.
2497149 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
19868
2/2
✓ Branch 0 taken 1120531 times.
✓ Branch 1 taken 4755786 times.
5876317 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
19869 {
19870
4/4
✓ Branch 0 taken 1895769 times.
✓ Branch 1 taken 2860017 times.
✓ Branch 2 taken 525473 times.
✓ Branch 3 taken 1370296 times.
4755786 if(get_bit(quest_rules,qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
19871
4/4
✓ Branch 0 taken 2253706 times.
✓ Branch 1 taken 1131784 times.
✓ Branch 2 taken 6554 times.
✓ Branch 3 taken 2247152 times.
3385490 if(lyr && !get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
19872 2247152 continue;
19873 1138338 cpos_info& cpinfo = get_combo_posinfo(lyr, combopos);
19874 1138338 mapscr* m = FFCore.tempScreens[lyr];
19875
2/2
✓ Branch 0 taken 1126852 times.
✓ Branch 1 taken 11486 times.
1138338 int cid = lyr == 0 ? MAPCOMBO(bx,by) : MAPCOMBOL(lyr,bx,by);
19876 1138338 newcombo const& cmb = combobuf[cid];
19877 1138338 int f = MAPFLAG2(lyr-1,bx,by);
19878 1138338 int f2 = cmb.flag;
19879 1138338 int t = cmb.type;
19880
19881
6/6
✓ Branch 0 taken 1038346 times.
✓ Branch 1 taken 99992 times.
✓ Branch 2 taken 1035587 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 2027 times.
✓ Branch 5 taken 1033560 times.
2171898 bool waitblock = (t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) ||
19882
1/2
✓ Branch 0 taken 1033560 times.
✗ Branch 1 not taken.
1033560 (t == cPUSHBLOCK && (cmb.usrflags&cflag6));
19883 1138338 int heavy = 0;
19884
4/4
✓ Branch 0 taken 1130647 times.
✓ Branch 1 taken 7691 times.
✓ Branch 2 taken 7911 times.
✓ Branch 3 taken 1122736 times.
1138338 if(t==cPUSH_HW || t==cPUSH_HEAVY)
19885 15602 heavy = 1;
19886
4/4
✓ Branch 0 taken 1121430 times.
✓ Branch 1 taken 1306 times.
✓ Branch 2 taken 2027 times.
✓ Branch 3 taken 1119403 times.
1122736 else if(t==cPUSH_HEAVY2 || t==cPUSH_HW2)
19887 3333 heavy = 2;
19888
1/2
✓ Branch 0 taken 1119403 times.
✗ Branch 1 not taken.
1119403 else if(t == cPUSHBLOCK)
19889 heavy = cmb.attribytes[0];
19890
19891
6/6
✓ Branch 0 taken 99846 times.
✓ Branch 1 taken 1038492 times.
✓ Branch 2 taken 34028 times.
✓ Branch 3 taken 65818 times.
✓ Branch 4 taken 2753 times.
✓ Branch 5 taken 31275 times.
1138338 if(waitblock && (pushing<16 || hasMainGuy())) continue;
19892
19893
8/8
✓ Branch 0 taken 10839 times.
✓ Branch 1 taken 1058928 times.
✓ Branch 2 taken 9936 times.
✓ Branch 3 taken 903 times.
✓ Branch 4 taken 741 times.
✓ Branch 5 taken 9195 times.
✓ Branch 6 taken 1644 times.
✓ Branch 7 taken 1068123 times.
1089801 if(heavy && (itemid<0 || glove->power < heavy ||
19894
3/4
✓ Branch 0 taken 9189 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
10839 (limitedpush && usecounts[itemid] > zc_max(1, glove->misc3)))) continue;
19895
19896 1068123 bool doit=false;
19897 1068123 bool changeflag=false;
19898 1068123 bool changecombo=false;
19899
19900 1068123 int blockdir = dir;
19901
1/2
✓ Branch 0 taken 1068123 times.
✗ Branch 1 not taken.
1068123 if(blockdir > 3) blockdir = Y_DIR(dir);
19902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1068123 times.
1068123 if(t == cPUSHBLOCK)
19903 {
19904 switch(blockdir)
19905 {
19906 case up:
19907 doit = cmb.usrflags & cflag1;
19908 break;
19909 case down:
19910 doit = cmb.usrflags & cflag2;
19911 break;
19912 case left:
19913 doit = cmb.usrflags & cflag3;
19914 break;
19915 case right:
19916 doit = cmb.usrflags & cflag4;
19917 break;
19918 }
19919 if(cmb.usrflags & cflag5) //Separate directions
19920 {
19921 if(int limit = cmb.attribytes[4+blockdir])
19922 {
19923 if(cpinfo.pushes[blockdir] >= limit)
19924 doit = false;
19925 }
19926 else if(cmb.usrflags & cflag9)
19927 doit = false;
19928 }
19929 else
19930 {
19931 if(int limit = cmb.attribytes[4])
19932 {
19933 if(cpinfo.sumpush() >= limit)
19934 doit = false;
19935 }
19936 else if(cmb.usrflags & cflag9)
19937 doit = false;
19938 }
19939 }
19940 else
19941 {
19942
8/8
✓ Branch 0 taken 1062995 times.
✓ Branch 1 taken 5128 times.
✓ Branch 2 taken 1062991 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 2741 times.
✓ Branch 5 taken 1065382 times.
✓ Branch 6 taken 367 times.
✓ Branch 7 taken 1060016 times.
2128506 if(((f==mfPUSHUD || f==mfPUSHUDNS|| f==mfPUSHUDINS) && dir<=down) ||
19943
4/4
✓ Branch 0 taken 1063062 times.
✓ Branch 1 taken 2320 times.
✓ Branch 2 taken 1063060 times.
✓ Branch 3 taken 2 times.
1065382 ((f==mfPUSHLR || f==mfPUSHLRNS|| f==mfPUSHLRINS) && dir>=left) ||
19944
4/4
✓ Branch 0 taken 1063045 times.
✓ Branch 1 taken 2337 times.
✓ Branch 2 taken 1062917 times.
✓ Branch 3 taken 128 times.
1065382 ((f==mfPUSHU || f==mfPUSHUNS || f==mfPUSHUINS) && dir==up) ||
19945
3/4
✓ Branch 0 taken 1063003 times.
✓ Branch 1 taken 2379 times.
✓ Branch 2 taken 1063003 times.
✗ Branch 3 not taken.
1065382 ((f==mfPUSHD || f==mfPUSHDNS || f==mfPUSHDINS) && dir==down) ||
19946
3/4
✓ Branch 0 taken 1062905 times.
✓ Branch 1 taken 2477 times.
✓ Branch 2 taken 1062905 times.
✗ Branch 3 not taken.
1065382 ((f==mfPUSHL || f==mfPUSHLNS || f==mfPUSHLINS) && dir==left) ||
19947
3/4
✓ Branch 0 taken 1062926 times.
✓ Branch 1 taken 2456 times.
✓ Branch 2 taken 1062926 times.
✗ Branch 3 not taken.
1065382 ((f==mfPUSHR || f==mfPUSHRNS || f==mfPUSHRINS) && dir==right) ||
19948
2/2
✓ Branch 0 taken 1060383 times.
✓ Branch 1 taken 87 times.
1060470 f==mfPUSH4 || f==mfPUSH4NS || f==mfPUSH4INS)
19949 {
19950 3195 changeflag=true;
19951 3195 doit=true;
19952 3195 }
19953
19954
7/8
✓ Branch 0 taken 1063191 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 1063191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 1063201 times.
✓ Branch 6 taken 1063190 times.
✓ Branch 7 taken 1 times.
2126392 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
19955
3/4
✓ Branch 0 taken 1063191 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1063191 times.
✗ Branch 3 not taken.
1063201 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
19956
3/4
✓ Branch 0 taken 1063191 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1063191 times.
✗ Branch 3 not taken.
1063201 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
19957
3/4
✓ Branch 0 taken 1063191 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1063191 times.
✗ Branch 3 not taken.
1063201 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
19958
3/4
✓ Branch 0 taken 1063191 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1063191 times.
✗ Branch 3 not taken.
1063201 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
19959
3/4
✓ Branch 0 taken 1063191 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1063191 times.
✗ Branch 3 not taken.
1063201 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
19960
1/2
✓ Branch 0 taken 1063181 times.
✗ Branch 1 not taken.
1063191 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
19961 {
19962 1 changecombo=true;
19963 1 doit=true;
19964 1 }
19965 }
19966
19967
2/2
✓ Branch 0 taken 314534 times.
✓ Branch 1 taken 748657 times.
1063191 if(get_bit(quest_rules,qr_SOLIDBLK))
19968 {
19969
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 82736 times.
✓ Branch 2 taken 73476 times.
✓ Branch 3 taken 71319 times.
✓ Branch 4 taken 87003 times.
314534 switch(blockdir)
19970 {
19971 case up:
19972
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 82736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82736 times.
✓ Branch 4 taken 51686 times.
✓ Branch 5 taken 31050 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 31050 times.
✓ Branch 8 taken 51690 times.
✓ Branch 9 taken 31046 times.
82736 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
19973
19974 82736 break;
19975
19976 case down:
19977
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 73476 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 73476 times.
✓ Branch 4 taken 44407 times.
✓ Branch 5 taken 29069 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 29069 times.
✓ Branch 8 taken 44411 times.
✓ Branch 9 taken 29065 times.
73476 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
19978
19979 73476 break;
19980
19981 case left:
19982
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 71319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71319 times.
✓ Branch 4 taken 31122 times.
✓ Branch 5 taken 40197 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 40197 times.
✓ Branch 8 taken 31128 times.
✓ Branch 9 taken 40191 times.
71319 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
19983
19984 71319 break;
19985
19986 case right:
19987
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 87003 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87003 times.
✓ Branch 4 taken 36627 times.
✓ Branch 5 taken 50376 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 50376 times.
✓ Branch 8 taken 36637 times.
✓ Branch 9 taken 50366 times.
87003 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
19988
19989 87003 break;
19990 }
19991 314534 }
19992
19993
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 386548 times.
✓ Branch 2 taken 329191 times.
✓ Branch 3 taken 165468 times.
✓ Branch 4 taken 181984 times.
1063191 switch(blockdir)
19994 {
19995 case up:
19996
3/4
✓ Branch 0 taken 386216 times.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 386216 times.
386548 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
19997
19998 386548 break;
19999
20000 case down:
20001
3/4
✓ Branch 0 taken 328775 times.
✓ Branch 1 taken 416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 328775 times.
329191 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
20002
20003 329191 break;
20004
20005 case left:
20006
3/4
✓ Branch 0 taken 165386 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 165386 times.
165468 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
20007
20008 165468 break;
20009
20010 case right:
20011
3/4
✓ Branch 0 taken 181960 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 181960 times.
181984 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
20012
20013 181984 break;
20014 }
20015
20016
2/2
✓ Branch 0 taken 1061801 times.
✓ Branch 1 taken 1390 times.
1063191 if(doit)
20017 {
20018
2/2
✓ Branch 0 taken 1383 times.
✓ Branch 1 taken 7 times.
1390 if(limitedpush)
20019 7 ++usecounts[itemid];
20020
20021 // for(int32_t i=0; i<1; i++)
20022
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1135 times.
1390 if(!blockmoving)
20023 {
20024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(changeflag)
20025 {
20026 1135 m->sflag[combopos]=0;
20027 1135 }
20028
20029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(mblock2.clk<=0)
20030 {
20031 1135 mblock2.blockLayer = lyr;
20032
20033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(t == cPUSHBLOCK)
20034 {
20035 zfix blockstep = 0.5;
20036 if(cmb.attrishorts[0] > 0)
20037 blockstep = zslongToFix(cmb.attrishorts[0]*100);
20038 mblock2.push_new(zfix(bx),zfix(by),blockdir,f,blockstep);
20039 mblock2.blockinfo = cpinfo;
20040 mblock2.blockinfo.push(blockdir, cmb.usrflags&cflag8);
20041 cpinfo.clear();
20042 if(cmb.attribytes[1])
20043 sfx(cmb.attribytes[1],(int32_t)x);
20044 }
20045 else
20046 {
20047 1135 mblock2.push((zfix)bx,(zfix)by,blockdir,f);
20048
20049
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1133 times.
1135 if(get_bit(quest_rules,qr_MORESOUNDS))
20050 2 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
20051 }
20052 1135 }
20053 1135 }
20054 1390 break;
20055 }
20056 1061801 }
20057 6390953 }
20058
20059 249 bool usekey()
20060 {
20061 249 int32_t itemid = current_item_id(itype_magickey);
20062
20063
3/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
249 if(itemid<0 ||
20064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
20065 : itemsbuf[itemid].power!=dlevel))
20066 {
20067
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 165 times.
200 if(game->lvlkeys[dlevel]!=0)
20068 {
20069 35 game->lvlkeys[dlevel]--;
20070 //run script for level key item
20071 35 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
20072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2975 times.
2975 for ( int32_t q = 0; q < MAXITEMS; ++q )
20073 {
20074
2/2
✓ Branch 0 taken 2940 times.
✓ Branch 1 taken 35 times.
2975 if ( itemsbuf[q].family == itype_lkey )
20075 {
20076 35 key_item = q; break;
20077 }
20078 2940 }
20079
20080
2/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
35 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20081 {
20082 int i = key_item;
20083 FFCore.reset_script_engine_data(ScriptType::Item, i);
20084 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
20085 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
20086 }
20087 35 return true;
20088 }
20089 else
20090 {
20091
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 124 times.
165 if(game->get_keys()==0)
20092 {
20093 41 return false;
20094 }
20095 else
20096 {
20097 //run script for key item
20098 124 int32_t key_item = 0; //current_item_id(itype_key); //not possible
20099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1240 times.
1240 for ( int32_t q = 0; q < MAXITEMS; ++q )
20100 {
20101
2/2
✓ Branch 0 taken 1116 times.
✓ Branch 1 taken 124 times.
1240 if ( itemsbuf[q].family == itype_key )
20102 {
20103 124 key_item = q; break;
20104 }
20105 1116 }
20106 //zprint2("key_item is: %d\n",key_item);
20107 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
20108
2/8
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
124 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20109 {
20110 int i = key_item;
20111 FFCore.reset_script_engine_data(ScriptType::Item, i);
20112 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
20113 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
20114 }
20115 124 game->change_keys(-1);
20116 }
20117 }
20118 124 }
20119
20120 173 return true;
20121 249 }
20122
20123 bool canUseKey(int32_t num)
20124 {
20125 int32_t itemid = current_item_id(itype_magickey);
20126
20127 if(itemid<0 ||
20128 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
20129 : itemsbuf[itemid].power!=dlevel))
20130 {
20131 return game->lvlkeys[dlevel] + game->get_keys() >= num;
20132 }
20133
20134 return true;
20135 }
20136
20137 bool usekey(int32_t num)
20138 {
20139 if(!canUseKey(num)) return false;
20140 for(auto q = 0; q < num; ++q)
20141 {
20142 if(!usekey()) return false; //should never return false here, but, just to be safe....
20143 }
20144 return true;
20145 }
20146
20147
20148 645 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
20149 {
20150 645 int32_t mc = (y&0xF0)+(x>>4);
20151
4/6
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 609 times.
✓ Branch 5 taken 36 times.
1290 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
20152
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 645 times.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 645 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 645 times.
✗ Branch 7 not taken.
645 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
20153
3/6
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 645 times.
✗ Branch 5 not taken.
645 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
20154
5/8
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 637 times.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 637 times.
645 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
20155 645 return ret;
20156 }
20157
20158 6379267 void HeroClass::oldchecklockblock()
20159 {
20160
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6365861 times.
6379267 if(toogam) return;
20161
20162 6365861 int32_t bx = x.getInt()&0xF0;
20163 6365861 int32_t bx2 = int32_t(x+8)&0xF0;
20164 6365861 int32_t by = y.getInt()&0xF0;
20165
20166
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1521387 times.
✓ Branch 2 taken 1225182 times.
✓ Branch 3 taken 1736487 times.
✓ Branch 4 taken 1882805 times.
6365861 switch(dir)
20167 {
20168 case up:
20169
4/4
✓ Branch 0 taken 274847 times.
✓ Branch 1 taken 1246540 times.
✓ Branch 2 taken 5789 times.
✓ Branch 3 taken 269058 times.
1521387 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20170
20171 1521387 break;
20172
20173 case down:
20174 1225182 by+=16;
20175 1225182 break;
20176
20177 case left:
20178
2/2
✓ Branch 0 taken 756479 times.
✓ Branch 1 taken 980008 times.
1736487 if((((int32_t)x)&0x0F)<8)
20179 980008 bx-=16;
20180
20181
2/2
✓ Branch 0 taken 1110887 times.
✓ Branch 1 taken 625600 times.
1736487 if(y.getInt()&8)
20182 {
20183 625600 by+=16;
20184 625600 }
20185
20186 1736487 bx2=bx;
20187 1736487 break;
20188
20189 case right:
20190 1882805 bx+=16;
20191
20192
2/2
✓ Branch 0 taken 1226114 times.
✓ Branch 1 taken 656691 times.
1882805 if(y.getInt()&8)
20193 {
20194 656691 by+=16;
20195 656691 }
20196
20197 1882805 bx2=bx;
20198 1882805 break;
20199 }
20200
20201 6365861 bool found1=false;
20202 6365861 bool found2=false;
20203 6365861 int32_t foundlayer = -1;
20204 6365861 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
20205 6365861 newcombo const& cmb = combobuf[cid1];
20206 6365861 newcombo const& cmb2 = combobuf[cid2];
20207 // Layer 0 is overridden by Locked Doors
20208
5/8
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 6365357 times.
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 504 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 504 times.
6365861 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
20209 {
20210 504 found1=true;
20211 504 foundlayer = 0;
20212 504 }
20213
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6365357 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6365357 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
20214 {
20215 found2=true;
20216 foundlayer = 0;
20217 }
20218
20219
2/2
✓ Branch 0 taken 12731722 times.
✓ Branch 1 taken 6365861 times.
19097583 for (int32_t i = 0; i <= 1; ++i)
20220 {
20221
2/2
✓ Branch 0 taken 10886140 times.
✓ Branch 1 taken 1845582 times.
12731722 if(tmpscr2[i].valid!=0)
20222 {
20223
2/2
✓ Branch 0 taken 1737727 times.
✓ Branch 1 taken 107855 times.
1845582 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20224 {
20225
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
20226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
20227 1737727 }
20228 else
20229 {
20230
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
20231
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
20232 }
20233 1845582 }
20234 12731722 }
20235
20236
20237 // Layers
20238
3/4
✓ Branch 0 taken 6365357 times.
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6365357 times.
6365861 if(!(found1 || found2))
20239 {
20240 6365357 foundlayer = -1;
20241
2/2
✓ Branch 0 taken 6365323 times.
✓ Branch 1 taken 12730680 times.
19096003 for(int32_t i=0; i<2; i++)
20242 {
20243 12730680 cid1 = MAPCOMBO2(i, bx, by);
20244 12730680 cid2 = MAPCOMBO2(i, bx2, by);
20245 12730680 newcombo const& cmb = combobuf[cid1];
20246 12730680 newcombo const& cmb2 = combobuf[cid2];
20247
2/2
✓ Branch 0 taken 6365323 times.
✓ Branch 1 taken 6365357 times.
12730680 if (i == 0)
20248 {
20249
2/2
✓ Branch 0 taken 5997852 times.
✓ Branch 1 taken 367505 times.
6365357 if(tmpscr2[1].valid!=0)
20250 {
20251
2/2
✓ Branch 0 taken 322951 times.
✓ Branch 1 taken 44554 times.
367505 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20252 {
20253
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 322951 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
322951 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
20254
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 322951 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
322951 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
20255 322951 }
20256 else
20257 {
20258
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20259
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20260 }
20261 367505 }
20262 6365357 }
20263
4/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 12730646 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
12730680 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
20264 {
20265 34 found1=true;
20266 34 foundlayer = i+1;
20267 //zprint("Found layer: %d \n", i);
20268 34 break;
20269 }
20270
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12730646 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12730646 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
20271 {
20272 found2=true;
20273 foundlayer = i+1;
20274 //zprint("Found layer: %d \n", i);
20275 break;
20276 }
20277 12730646 }
20278 6365357 }
20279
20280
4/4
✓ Branch 0 taken 6365323 times.
✓ Branch 1 taken 538 times.
✓ Branch 2 taken 6365812 times.
✓ Branch 3 taken 49 times.
6365861 if(!(found1 || found2) || pushing<8)
20281 {
20282 6365812 return;
20283 }
20284
1/2
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
49 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
20285
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 31 times.
49 if(!try_locked_combo(cmb3))
20286 31 return;
20287
20288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(cmb.usrflags&cflag16)
20289 {
20290 setxmapflag(1<<cmb.attribytes[5]);
20291 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
20292 }
20293 else
20294 {
20295 18 setmapflag(mLOCKBLOCK);
20296 18 remove_lockblocks((currscr>=128)?1:0);
20297 }
20298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( cmb3.usrflags&cflag3 )
20299 {
20300 if ( (cmb3.attribytes[3]) )
20301 sfx(cmb3.attribytes[3]);
20302 }
20303 18 else sfx(WAV_DOOR);
20304 6379267 }
20305
20306 6379267 void HeroClass::oldcheckbosslockblock()
20307 {
20308
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6365861 times.
6379267 if(toogam) return;
20309
20310 6365861 int32_t bx = x.getInt()&0xF0;
20311 6365861 int32_t bx2 = int32_t(x+8)&0xF0;
20312 6365861 int32_t by = y.getInt()&0xF0;
20313
20314
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1521387 times.
✓ Branch 2 taken 1225182 times.
✓ Branch 3 taken 1736487 times.
✓ Branch 4 taken 1882805 times.
6365861 switch(dir)
20315 {
20316 case up:
20317
4/4
✓ Branch 0 taken 274847 times.
✓ Branch 1 taken 1246540 times.
✓ Branch 2 taken 5789 times.
✓ Branch 3 taken 269058 times.
1521387 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20318
20319 1521387 break;
20320
20321 case down:
20322 1225182 by+=16;
20323 1225182 break;
20324
20325 case left:
20326
2/2
✓ Branch 0 taken 756479 times.
✓ Branch 1 taken 980008 times.
1736487 if((((int32_t)x)&0x0F)<8)
20327 980008 bx-=16;
20328
20329
2/2
✓ Branch 0 taken 1110887 times.
✓ Branch 1 taken 625600 times.
1736487 if(y.getInt()&8)
20330 {
20331 625600 by+=16;
20332 625600 }
20333
20334 1736487 bx2=bx;
20335 1736487 break;
20336
20337 case right:
20338 1882805 bx+=16;
20339
20340
2/2
✓ Branch 0 taken 1226114 times.
✓ Branch 1 taken 656691 times.
1882805 if(y.getInt()&8)
20341 {
20342 656691 by+=16;
20343 656691 }
20344
20345 1882805 bx2=bx;
20346 1882805 break;
20347 }
20348
20349
20350 6365861 bool found1 = false;
20351 6365861 bool found2 = false;
20352 6365861 int32_t foundlayer = -1;
20353 6365861 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
20354 6365861 newcombo const& cmb = combobuf[cid1];
20355 6365861 newcombo const& cmb2 = combobuf[cid2];
20356 // Layer 0 is overridden by Locked Doors
20357
5/8
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 6365720 times.
✓ Branch 2 taken 141 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 141 times.
6365861 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
20358 {
20359 141 found1 = true;
20360 141 foundlayer = 0;
20361 141 }
20362
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6365720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6365720 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
20363 {
20364 found2 = true;
20365 foundlayer = 0;
20366 }
20367
20368
2/2
✓ Branch 0 taken 12731722 times.
✓ Branch 1 taken 6365861 times.
19097583 for (int32_t i = 0; i <= 1; ++i)
20369 {
20370
2/2
✓ Branch 0 taken 10886140 times.
✓ Branch 1 taken 1845582 times.
12731722 if (tmpscr2[i].valid != 0)
20371 {
20372
2/2
✓ Branch 0 taken 1737727 times.
✓ Branch 1 taken 107855 times.
1845582 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20373 {
20374
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
20375
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
20376 1737727 }
20377 else
20378 {
20379
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
20380
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
20381 }
20382 1845582 }
20383 12731722 }
20384
20385
20386 // Layers
20387
3/4
✓ Branch 0 taken 6365720 times.
✓ Branch 1 taken 141 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6365720 times.
6365861 if (!(found1 || found2))
20388 {
20389 6365720 foundlayer = -1;
20390
2/2
✓ Branch 0 taken 6365720 times.
✓ Branch 1 taken 12731440 times.
19097160 for (int32_t i = 0; i < 2; i++)
20391 {
20392 12731440 cid1 = MAPCOMBO2(i, bx, by);
20393 12731440 cid2 = MAPCOMBO2(i, bx2, by);
20394 12731440 newcombo const& cmb = combobuf[cid1];
20395 12731440 newcombo const& cmb2 = combobuf[cid2];
20396
2/2
✓ Branch 0 taken 6365720 times.
✓ Branch 1 taken 6365720 times.
12731440 if (i == 0)
20397 {
20398
2/2
✓ Branch 0 taken 5998072 times.
✓ Branch 1 taken 367648 times.
6365720 if (tmpscr2[1].valid != 0)
20399 {
20400
2/2
✓ Branch 0 taken 323030 times.
✓ Branch 1 taken 44618 times.
367648 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20401 {
20402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 323030 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
323030 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
20403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 323030 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
323030 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
20404 323030 }
20405 else
20406 {
20407
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
20408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
20409 }
20410 367648 }
20411 6365720 }
20412
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12731440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12731440 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
20413 {
20414 found1 = true;
20415 foundlayer = i;
20416 break;
20417 }
20418
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12731440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12731440 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
20419 {
20420 found2 = true;
20421 foundlayer = i;
20422 break;
20423 }
20424 12731440 }
20425 6365720 }
20426
20427
4/4
✓ Branch 0 taken 6365720 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 6365839 times.
✓ Branch 3 taken 22 times.
6365861 if (!(found1 || found2) || pushing < 8)
20428 {
20429 6365839 return;
20430 }
20431
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 int32_t cid = found1 ? cid1 : cid2;
20432
20433
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 17 times.
22 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
20434
20435
20436 // Run Boss Key Script
20437 5 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
20438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 for ( int32_t q = 0; q < MAXITEMS; ++q )
20439 {
20440
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 5 times.
340 if ( itemsbuf[q].family == itype_bosskey )
20441 {
20442 5 key_item = q; break;
20443 }
20444 335 }
20445
2/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20446 {
20447 int i = key_item;
20448 FFCore.reset_script_engine_data(ScriptType::Item, i);
20449 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
20450 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
20451 }
20452
20453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(cmb.usrflags&cflag16)
20454 {
20455 setxmapflag(1<<cmb.attribytes[5]);
20456 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
20457 }
20458 else
20459 {
20460 5 setmapflag(mBOSSLOCKBLOCK);
20461 5 remove_bosslockblocks((currscr>=128)?1:0);
20462 }
20463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if ( (combobuf[cid].attribytes[3]) )
20464 5 sfx(combobuf[cid].attribytes[3]);
20465 6379267 }
20466
20467 18748800 void HeroClass::oldcheckchest(int32_t type)
20468 {
20469 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
20470
5/6
✓ Branch 0 taken 18708582 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 18699525 times.
✓ Branch 3 taken 9057 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18699525 times.
18748800 if(toogam || z>0 || fakez > 0) return;
20471
2/2
✓ Branch 0 taken 17810718 times.
✓ Branch 1 taken 888807 times.
18699525 if(pushing<8) return;
20472 888807 int32_t bx = x.getInt()&0xF0;
20473 888807 int32_t bx2 = int32_t(x+8)&0xF0;
20474 888807 int32_t by = y.getInt()&0xF0;
20475
20476
3/4
✓ Branch 0 taken 498624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179772 times.
✓ Branch 3 taken 210411 times.
888807 switch(dir)
20477 {
20478 case up:
20479
2/2
✓ Branch 0 taken 40752 times.
✓ Branch 1 taken 169659 times.
210411 if(isSideViewHero()) return;
20480
20481
4/4
✓ Branch 0 taken 49866 times.
✓ Branch 1 taken 119793 times.
✓ Branch 2 taken 48696 times.
✓ Branch 3 taken 1170 times.
169659 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20482
20483 169659 break;
20484
20485 case left:
20486 case right:
20487
2/2
✓ Branch 0 taken 16173 times.
✓ Branch 1 taken 482451 times.
498624 if(isSideViewHero()) break;
20488 [[fallthrough]];
20489 case down:
20490 662223 return;
20491 }
20492
20493 185832 bool found=false;
20494 185832 bool itemflag=false;
20495
20496
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 185824 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
185832 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
20497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185824 times.
185824 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
20498 {
20499 8 found=true;
20500 8 }
20501
2/2
✓ Branch 0 taken 371664 times.
✓ Branch 1 taken 185832 times.
557496 for (int32_t i = 0; i <= 1; ++i)
20502 {
20503
2/2
✓ Branch 0 taken 323724 times.
✓ Branch 1 taken 47940 times.
371664 if(tmpscr2[i].valid!=0)
20504 {
20505
2/2
✓ Branch 0 taken 47079 times.
✓ Branch 1 taken 861 times.
47940 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20506 {
20507
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47079 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
20508
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47079 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
20509 47079 }
20510 else
20511 {
20512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
20513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
20514 }
20515 47940 }
20516 371664 }
20517
20518
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 185824 times.
185832 if(!found)
20519 {
20520
2/2
✓ Branch 0 taken 185824 times.
✓ Branch 1 taken 371648 times.
557472 for(int32_t i=0; i<2; i++)
20521 {
20522
2/2
✓ Branch 0 taken 185824 times.
✓ Branch 1 taken 185824 times.
371648 if (i == 0)
20523 {
20524
2/2
✓ Branch 0 taken 177649 times.
✓ Branch 1 taken 8175 times.
185824 if(tmpscr2[1].valid!=0)
20525 {
20526
2/2
✓ Branch 0 taken 7794 times.
✓ Branch 1 taken 381 times.
8175 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20527 {
20528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7794 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7794 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20530 7794 }
20531 else
20532 {
20533
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20534
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20535 }
20536 8175 }
20537 185824 }
20538
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 371648 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
371648 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
20539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 371648 times.
371648 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
20540 {
20541 found=true;
20542 break;
20543 }
20544 371648 }
20545 185824 }
20546
20547
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 185824 times.
185832 if(!found)
20548 {
20549 185824 return;
20550 }
20551
20552
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 switch(type)
20553 {
20554 case cLOCKEDCHEST:
20555 if(!usekey()) return;
20556
20557 setmapflag(mLOCKEDCHEST);
20558 break;
20559
20560 case cCHEST:
20561 8 setmapflag(mCHEST);
20562 8 break;
20563
20564 case cBOSSCHEST:
20565 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
20566 // Run Boss Key Script
20567 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
20568 for ( int32_t q = 0; q < MAXITEMS; ++q )
20569 {
20570 if ( itemsbuf[q].family == itype_bosskey )
20571 {
20572 key_item = q; break;
20573 }
20574 }
20575 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20576 {
20577 int i = key_item;
20578 FFCore.reset_script_engine_data(ScriptType::Item, i);
20579 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
20580 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
20581 }
20582 setmapflag(mBOSSCHEST);
20583 break;
20584 }
20585
20586 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
20587 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
20588 8 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
20589 8 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
20590 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
20591 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
20592
20593
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!itemflag)
20594 {
20595 for(int32_t i=0; i<2; i++)
20596 {
20597 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
20598 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
20599 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
20600 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
20601 }
20602 }
20603
20604
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
8 if(itemflag && !getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
20605 {
20606
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
8 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
20607 8 }
20608 18748800 }
20609
20610 472075 void HeroClass::checkchest(int32_t type)
20611 {
20612
4/4
✓ Branch 0 taken 325796 times.
✓ Branch 1 taken 146279 times.
✓ Branch 2 taken 146279 times.
✓ Branch 3 taken 179517 times.
472075 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
20613
2/2
✓ Branch 0 taken 16619 times.
✓ Branch 1 taken 455456 times.
472075 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
20614
2/2
✓ Branch 0 taken 16619 times.
✓ Branch 1 taken 455456 times.
472075 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
20615
2/2
✓ Branch 0 taken 16619 times.
✓ Branch 1 taken 455456 times.
472075 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
20616
2/2
✓ Branch 0 taken 33238 times.
✓ Branch 1 taken 438837 times.
472075 if(ischest)
20617 {
20618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 438837 times.
438837 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
20619 {
20620 oldcheckchest(type);
20621 return;
20622 }
20623 438837 }
20624
3/4
✓ Branch 0 taken 33238 times.
✓ Branch 1 taken 438837 times.
✓ Branch 2 taken 33238 times.
✗ Branch 3 not taken.
472075 if(islockblock && get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
20625 {
20626 if(type == cLOCKBLOCK)
20627 oldchecklockblock();
20628 else if(type == cBOSSLOCKBLOCK)
20629 oldcheckbosslockblock();
20630 return;
20631 }
20632
4/6
✓ Branch 0 taken 472075 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 468119 times.
✓ Branch 3 taken 3956 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 468119 times.
472075 if(toogam || z>0 || fakez > 0) return;
20633 468119 zfix bx, by;
20634 468119 zfix bx2, by2;
20635 468119 zfix fx(-1), fy(-1);
20636
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 103883 times.
✓ Branch 2 taken 110059 times.
✓ Branch 3 taken 120179 times.
✓ Branch 4 taken 133998 times.
468119 switch(dir)
20637 {
20638 case up:
20639 103883 by = y + (bigHitbox ? -2 : 6);
20640 103883 by2 = by;
20641 103883 bx = x + 4;
20642 103883 bx2 = bx + 8;
20643 103883 break;
20644 case down:
20645 110059 by = y + 17;
20646 110059 by2 = by;
20647 110059 bx = x + 4;
20648 110059 bx2 = bx + 8;
20649 110059 break;
20650 case left:
20651 120179 by = y + (bigHitbox ? 0 : 8);
20652 120179 by2 = y + 8;
20653 120179 bx = x - 2;
20654 120179 bx2 = x - 2;
20655 120179 break;
20656 case right:
20657 133998 by = y + (bigHitbox ? 0 : 8);
20658 133998 by2 = y + 8;
20659 133998 bx = x + 17;
20660 133998 bx2 = x + 17;
20661 133998 break;
20662 }
20663
20664 468119 int32_t found = -1;
20665 468119 int32_t foundlayer = 0;
20666
20667 468119 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
20668
20669
4/6
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 467248 times.
✓ Branch 2 taken 871 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 871 times.
468119 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
20670 {
20671 871 found = MAPCOMBO(bx,by);
20672 871 fx = bx; fy = by;
20673
2/2
✓ Branch 0 taken 1742 times.
✓ Branch 1 taken 871 times.
2613 for (int32_t i = 0; i <= 1; ++i)
20674 {
20675
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1357 times.
1742 if(tmpscr2[i].valid!=0)
20676 {
20677
1/2
✓ Branch 0 taken 1357 times.
✗ Branch 1 not taken.
1357 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20678 {
20679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1357 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1357 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20680 1357 }
20681 else
20682 {
20683 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20684 }
20685 1357 }
20686 1742 }
20687 871 }
20688
2/2
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 467248 times.
468119 if(found<0)
20689 {
20690 467248 cmb = &combobuf[MAPCOMBO(bx2,by2)];
20691
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 467225 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
467248 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
20692 {
20693 23 found = MAPCOMBO(bx2,by2);
20694
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 161 times.
184 for (int32_t i = 0; i <= 6; ++i)
20695 {
20696
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 46 times.
161 if(tmpscr2[i].valid!=0)
20697 {
20698
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20699 {
20700
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
20701 {
20702 found = -1;
20703 break;
20704 }
20705 46 }
20706 else
20707 {
20708 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
20709 {
20710 found = -1;
20711 break;
20712 }
20713 }
20714 46 }
20715 161 }
20716
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(found != -1)
20717 {
20718 23 fx = bx2; fy = by2;
20719 23 }
20720 23 }
20721 467248 }
20722
20723
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 467225 times.
468119 if(found<0)
20724 {
20725
2/2
✓ Branch 0 taken 467172 times.
✓ Branch 1 taken 2803085 times.
3270257 for(int32_t i=0; i<6; i++)
20726 {
20727 2803085 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
20728
4/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 2803032 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
2803085 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
20729 {
20730 53 found = MAPCOMBO2(i,bx,by);
20731
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 265 times.
318 for(int32_t j = i+1; j < 6; ++j)
20732 {
20733
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 53 times.
265 if (tmpscr2[j].valid!=0)
20734 {
20735
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20736 {
20737
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
20738 {
20739 found = -1;
20740 break;
20741 }
20742 53 }
20743 else
20744 {
20745 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
20746 {
20747 found = -1;
20748 break;
20749 }
20750 }
20751 53 }
20752 265 }
20753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(found>-1)
20754 {
20755 53 foundlayer = i+1;
20756 53 fx = bx; fy = by;
20757 53 break;
20758 }
20759 }
20760 2803032 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
20761
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2803032 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2803032 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
20762 {
20763 found = MAPCOMBO2(i,bx2,by2);
20764 for(int32_t j = i+1; j < 6; ++j)
20765 {
20766 if (tmpscr2[j].valid!=0)
20767 {
20768 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20769 {
20770 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
20771 {
20772 found = -1;
20773 break;
20774 }
20775 }
20776 else
20777 {
20778 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
20779 {
20780 found = -1;
20781 break;
20782 }
20783 }
20784 }
20785 }
20786 if(found>-1)
20787 {
20788 foundlayer = i+1;
20789 fx = bx2; fy = by2;
20790 break;
20791 }
20792 }
20793 2803032 }
20794 467225 }
20795
20796
2/2
✓ Branch 0 taken 947 times.
✓ Branch 1 taken 467172 times.
468119 if(found<0) return;
20797 947 cmb = &combobuf[found];
20798
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
947 switch(dir)
20799 {
20800 case up:
20801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags&cflag10)
20802 return;
20803 947 break;
20804 case down:
20805 if(cmb->usrflags&cflag9)
20806 return;
20807 break;
20808 case left:
20809 if(cmb->usrflags&cflag12)
20810 return;
20811 break;
20812 case right:
20813 if(cmb->usrflags&cflag11)
20814 return;
20815 break;
20816 }
20817 947 int32_t intbtn = cmb->attribytes[2];
20818
20819
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(intbtn) //
20820 {
20821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags & cflag13) //display prompt
20822 {
20823 947 int altcmb = cmb->attributes[2]/10000;
20824 947 prompt_combo = cmb->attributes[1]/10000;
20825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
947 if(altcmb && ((islocked && !can_locked_combo(*cmb))
20826 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
20827 prompt_combo = altcmb;
20828 947 prompt_cset = cmb->attribytes[4];
20829 947 prompt_x = cmb->attrishorts[0];
20830 947 prompt_y = cmb->attrishorts[1];
20831 947 }
20832
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 935 times.
947 if(!getIntBtnInput(intbtn, true, true, false, false))
20833 {
20834 935 return; //Button not pressed
20835 }
20836 12 }
20837 else if(pushing < 8 || pushing % 8) return; //Not pushing against chest enough
20838
20839
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(ischest)
20840 {
20841
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
20842 12 }
20843 else if(islockblock)
20844 {
20845 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
20846 }
20847
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(intbtn && (cmb->usrflags & cflag13))
20848 12 prompt_combo = 0;
20849 472075 }
20850
20851 6406501 void HeroClass::checkgenpush()
20852 {
20853
4/4
✓ Branch 0 taken 300646 times.
✓ Branch 1 taken 6105855 times.
✓ Branch 2 taken 256811 times.
✓ Branch 3 taken 43835 times.
6406501 if(pushing < 8 || pushing % 8) return;
20854 43835 zfix bx, by;
20855 43835 zfix bx2, by2;
20856
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10528 times.
✓ Branch 2 taken 9101 times.
✓ Branch 3 taken 11604 times.
✓ Branch 4 taken 12602 times.
43835 switch(dir)
20857 {
20858 case up:
20859 10528 by = y + (bigHitbox ? -2 : 6);
20860 10528 by2 = by;
20861 10528 bx = x + 4;
20862 10528 bx2 = bx + 8;
20863 10528 break;
20864 case down:
20865 9101 by = y + 17;
20866 9101 by2 = by;
20867 9101 bx = x + 4;
20868 9101 bx2 = bx + 8;
20869 9101 break;
20870 case left:
20871 11604 by = y + (bigHitbox ? 0 : 8);
20872 11604 by2 = y + 8;
20873 11604 bx = x - 2;
20874 11604 bx2 = x - 2;
20875 11604 break;
20876 case right:
20877 12602 by = y + (bigHitbox ? 0 : 8);
20878 12602 by2 = y + 8;
20879 12602 bx = x + 17;
20880 12602 bx2 = x + 17;
20881 12602 break;
20882 }
20883 43835 auto pos1 = COMBOPOS(bx,by);
20884 43835 auto pos2 = COMBOPOS(bx2,by2);
20885
2/2
✓ Branch 0 taken 43835 times.
✓ Branch 1 taken 306845 times.
350680 for(auto layer = 0; layer < 7; ++layer)
20886 {
20887 306845 mapscr* tmp = FFCore.tempScreens[layer];
20888
20889 306845 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
20890
2/2
✓ Branch 0 taken 306844 times.
✓ Branch 1 taken 1 times.
306845 if(cmb1.triggerflags[1] & combotriggerPUSH)
20891 1 do_trigger_combo(layer,pos1);
20892
20893
2/2
✓ Branch 0 taken 259238 times.
✓ Branch 1 taken 47607 times.
306845 if(pos1==pos2) continue;
20894
20895 47607 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
20896
1/2
✓ Branch 0 taken 47607 times.
✗ Branch 1 not taken.
47607 if(cmb2.triggerflags[1] & combotriggerPUSH)
20897 do_trigger_combo(layer,pos2);
20898 47607 }
20899
2/2
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 43078 times.
43835 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
20900 {
20901 757 word c = tmpscr->numFFC();
20902
2/2
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 4337 times.
5094 for(word i=0; i<c; i++)
20903 {
20904
4/4
✓ Branch 0 taken 4285 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 4277 times.
4337 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
20905 {
20906 60 ffcdata& ffc = tmpscr->ffcs[i];
20907 60 newcombo const& cmb3 = combobuf[ffc.getData()];
20908
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(cmb3.triggerflags[1] & combotriggerPUSH)
20909 {
20910 do_trigger_combo_ffc(i);
20911 break;
20912 }
20913 60 }
20914 4337 }
20915 757 }
20916 6406501 }
20917
20918 6406502 void HeroClass::checksigns() //Also checks for generic trigger buttons
20919 {
20920
5/6
✓ Branch 0 taken 6393096 times.
✓ Branch 1 taken 13406 times.
✓ Branch 2 taken 6389179 times.
✓ Branch 3 taken 3917 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6389179 times.
6406502 if(toogam || z>0 || fakez>0) return;
20921
5/6
✓ Branch 0 taken 6340824 times.
✓ Branch 1 taken 48355 times.
✓ Branch 2 taken 107120 times.
✓ Branch 3 taken 6233704 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 107120 times.
6389179 if(msg_active || (msg_onscreen && get_bit(quest_rules, qr_MSGDISAPPEAR)))
20922 48355 return; //Don't overwrite a message waiting to be dismissed
20923 6340824 zfix bx, by;
20924 6340824 zfix bx2, by2;
20925 6340824 zfix fx(-1), fy(-1);
20926
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1484950 times.
✓ Branch 2 taken 1228293 times.
✓ Branch 3 taken 1735301 times.
✓ Branch 4 taken 1892280 times.
6340824 switch(dir)
20927 {
20928 case up:
20929 1484950 by = y + (bigHitbox ? -2 : 6);
20930 1484950 by2 = by;
20931 1484950 bx = x + 4;
20932 1484950 bx2 = bx + 8;
20933 1484950 break;
20934 case down:
20935 1228293 by = y + 17;
20936 1228293 by2 = by;
20937 1228293 bx = x + 4;
20938 1228293 bx2 = bx + 8;
20939 1228293 break;
20940 case left:
20941 1735301 by = y + (bigHitbox ? 0 : 8);
20942 1735301 by2 = y + 8;
20943 1735301 bx = x - 2;
20944 1735301 bx2 = x - 2;
20945 1735301 break;
20946 case right:
20947 1892280 by = y + (bigHitbox ? 0 : 8);
20948 1892280 by2 = y + 8;
20949 1892280 bx = x + 17;
20950 1892280 bx2 = x + 17;
20951 1892280 break;
20952 }
20953
20954 6340824 int32_t found = -1;
20955 6340824 int32_t foundffc = -1;
20956 6340824 int32_t found_lyr = 0;
20957 6340824 bool found_sign = false;
20958 6340824 int32_t tmp_cid = MAPCOMBO(bx,by);
20959 6340824 newcombo const* tmp_cmb = &combobuf[tmp_cid];
20960
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6340824 times.
✓ Branch 2 taken 6340178 times.
✓ Branch 3 taken 646 times.
12681648 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
20961 6340824 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
20962 {
20963 646 found = tmp_cid;
20964 646 fx = bx; fy = by;
20965
2/2
✓ Branch 0 taken 1292 times.
✓ Branch 1 taken 646 times.
1938 for (int32_t i = 0; i <= 1; ++i)
20966 {
20967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
1292 if(tmpscr2[i].valid!=0)
20968 {
20969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
1292 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20970 {
20971 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20972 }
20973 else
20974 {
20975
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1292 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20976 }
20977 1292 }
20978 1292 }
20979 646 }
20980 6340824 tmp_cid = MAPCOMBO(bx2,by2);
20981 6340824 tmp_cmb = &combobuf[tmp_cid];
20982
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6340824 times.
✓ Branch 2 taken 6340238 times.
✓ Branch 3 taken 586 times.
12681648 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
20983 6340824 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
20984 {
20985 586 found = tmp_cid;
20986 586 fx = bx2; fy = by2;
20987
2/2
✓ Branch 0 taken 1172 times.
✓ Branch 1 taken 586 times.
1758 for (int32_t i = 0; i <= 1; ++i)
20988 {
20989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
1172 if(tmpscr2[i].valid!=0)
20990 {
20991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
1172 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20992 {
20993 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
20994 }
20995 else
20996 {
20997
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1172 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
20998 }
20999 1172 }
21000 1172 }
21001 586 }
21002
21003
2/2
✓ Branch 0 taken 6196048 times.
✓ Branch 1 taken 144776 times.
6340824 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
21004 {
21005 144776 word c = tmpscr->numFFC();
21006
2/2
✓ Branch 0 taken 144776 times.
✓ Branch 1 taken 621626 times.
766402 for(word i=0; i<c; i++)
21007 {
21008
4/4
✓ Branch 0 taken 615865 times.
✓ Branch 1 taken 5761 times.
✓ Branch 2 taken 463 times.
✓ Branch 3 taken 615402 times.
621626 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
21009 {
21010 6224 ffcdata& ffc = tmpscr->ffcs[i];
21011 6224 tmp_cmb = &combobuf[ffc.getData()];
21012
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6224 times.
6224 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
21013 6224 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
21014 {
21015 foundffc = i;
21016 break;
21017 }
21018 6224 }
21019 621626 }
21020 144776 }
21021
21022
3/4
✓ Branch 0 taken 6340175 times.
✓ Branch 1 taken 649 times.
✓ Branch 2 taken 6340175 times.
✗ Branch 3 not taken.
6340824 if(found<0 && foundffc < 0)
21023 {
21024
2/2
✓ Branch 0 taken 6339603 times.
✓ Branch 1 taken 38038190 times.
44377793 for(int32_t i=0; i<6; i++)
21025 {
21026 38038190 tmp_cid = MAPCOMBO2(i,bx,by);
21027 38038190 tmp_cmb = &combobuf[tmp_cid];
21028
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38038190 times.
✓ Branch 2 taken 38037618 times.
✓ Branch 3 taken 572 times.
76076380 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
21029 38038190 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
21030 {
21031 572 found = tmp_cid;
21032 572 found_lyr = i+1;
21033 572 fx = bx; fy = by;
21034
3/4
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 440 times.
572 if (i == 0 && tmpscr2[1].valid!=0)
21035 {
21036
1/2
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
440 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
21037 {
21038
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
440 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
21039 440 }
21040 else
21041 {
21042 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
21043 }
21044 440 }
21045 572 }
21046 38038190 tmp_cid = MAPCOMBO2(i,bx2,by2);
21047 38038190 tmp_cmb = &combobuf[tmp_cid];
21048
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38038190 times.
✓ Branch 2 taken 38037674 times.
✓ Branch 3 taken 516 times.
76076380 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
21049 38038190 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
21050 {
21051 516 found = tmp_cid;
21052 516 found_lyr = i+1;
21053 516 fx = bx2; fy = by2;
21054
3/4
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 390 times.
516 if (i == 0 && tmpscr2[1].valid!=0)
21055 {
21056
1/2
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
390 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
21057 {
21058
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
390 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
21059 390 }
21060 else
21061 {
21062 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
21063 }
21064 390 }
21065 516 }
21066
2/2
✓ Branch 0 taken 38037618 times.
✓ Branch 1 taken 572 times.
38038190 if(found>-1) break;
21067 38037618 }
21068 6340175 }
21069
21070
3/4
✓ Branch 0 taken 6339603 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 6339603 times.
✗ Branch 3 not taken.
6340824 if(found<0&&foundffc<0) return;
21071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].getData()]);
21072
21073 1221 byte signInput = 0;
21074 1221 bool didsign = false, didprompt = false;
21075
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1221 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
21076 {
21077 switch(dir)
21078 {
21079 case up:
21080 if(cmb.usrflags&cflag10)
21081 goto endsigns;
21082 break;
21083 case down:
21084 if(cmb.usrflags&cflag9)
21085 goto endsigns;
21086 break;
21087 case left:
21088 if(cmb.usrflags&cflag12)
21089 goto endsigns;
21090 break;
21091 case right:
21092 if(cmb.usrflags&cflag11)
21093 goto endsigns;
21094 break;
21095 }
21096 int32_t intbtn = cmb.attribytes[2];
21097
21098 if(intbtn) //
21099 {
21100 signInput = getIntBtnInput(intbtn, true, true, false, false);
21101 if(!signInput)
21102 {
21103 if(cmb.usrflags & cflag13) //display prompt
21104 {
21105 prompt_combo = cmb.attributes[1]/10000;
21106 prompt_cset = cmb.attribytes[4];
21107 prompt_x = cmb.attrishorts[0];
21108 prompt_y = cmb.attrishorts[1];
21109 didprompt = true;
21110 }
21111 goto endsigns; //Button not pressed
21112 }
21113 }
21114 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
21115
21116 trigger_sign(cmb);
21117 didsign = true;
21118 }
21119 endsigns:
21120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 if(on_cooldown(found_lyr, COMBOPOS(fx,fy))) return;
21121
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 431 times.
✓ Branch 3 taken 309 times.
✓ Branch 4 taken 228 times.
1221 switch(dir)
21122 {
21123 case down:
21124
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
21125 return;
21126 253 break;
21127 case up:
21128
1/2
✓ Branch 0 taken 431 times.
✗ Branch 1 not taken.
431 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
21129 return;
21130 431 break;
21131 case right:
21132
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
21133 return;
21134 309 break;
21135 case left:
21136
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 75 times.
228 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
21137 75 return;
21138 153 break;
21139 }
21140
4/6
✓ Branch 0 taken 1146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1114 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1114 times.
1146 if(cmb.triggerbtn && (getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput)))
21141 {
21142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if (foundffc >= 0)
21143 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
21144 else
21145 32 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
21146 32 }
21147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(didprompt)
21148 return;
21149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(cmb.type == cBUTTONPROMPT)
21150 {
21151 prompt_combo = cmb.attributes[0]/10000;
21152 prompt_cset = cmb.attribytes[0];
21153 prompt_x = cmb.attrishorts[0];
21154 prompt_y = cmb.attrishorts[1];
21155 }
21156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(cmb.prompt_cid)
21157 {
21158 1114 prompt_combo = cmb.prompt_cid;
21159 1114 prompt_cset = cmb.prompt_cs;
21160 1114 prompt_x = cmb.prompt_x;
21161 1114 prompt_y = cmb.prompt_y;
21162 1114 }
21163 6406502 }
21164
21165 6395885 void HeroClass::checklocked()
21166 {
21167
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6382479 times.
6395885 if(toogam) return; //Walk through walls.
21168
21169
2/2
✓ Branch 0 taken 3646327 times.
✓ Branch 1 taken 2736152 times.
6382479 if(!isdungeon()) return;
21170
21171
4/4
✓ Branch 0 taken 3645689 times.
✓ Branch 1 taken 638 times.
✓ Branch 2 taken 7738 times.
✓ Branch 3 taken 3637951 times.
3646327 if( !diagonalMovement && pushing!=8) return;
21172 /*This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
21173 */
21174
4/4
✓ Branch 0 taken 638 times.
✓ Branch 1 taken 7738 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 628 times.
8376 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
21175
21176
21177 7748 bool found = false;
21178
2/2
✓ Branch 0 taken 30992 times.
✓ Branch 1 taken 7748 times.
38740 for ( int32_t q = 0; q < 4; q++ ) {
21179
4/4
✓ Branch 0 taken 30264 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 30018 times.
30992 if ( tmpscr->door[q] == dLOCKED || tmpscr->door[q] == dBOSS ) { found = true; }
21180 30992 }
21181
21182
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 6805 times.
7748 if ( !found ) return;
21183
21184 943 int32_t si = (currmap<<7) + currscr;
21185 943 int32_t di = 0;
21186
21187
21188
21189
2/4
✓ Branch 0 taken 943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 943 times.
943 if ( diagonalMovement || get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
21190 {
21191 //Up door
21192 if ( y <= 32 && x >= 112 && x <= 128 )
21193 {
21194 if (
21195 dir == up || dir == l_up || dir == r_up //|| Up() || ( Up()&&Left()) || ( Up()&&Right())
21196
21197 )
21198 {
21199 di = nextscr(up);
21200 if(tmpscr->door[0]==dLOCKED)
21201 {
21202 if(usekey())
21203 {
21204 putdoor(scrollbuf,0,up,dUNLOCKED);
21205 tmpscr->door[0]=dUNLOCKED;
21206 setmapflag(si, mDOOR_UP);
21207
21208 if(di != 0xFFFF)
21209 setmapflag(di, mDOOR_DOWN);
21210 sfx(WAV_DOOR);
21211 markBmap(-1);
21212 }
21213 else return;
21214 }
21215 else if(tmpscr->door[0]==dBOSS)
21216 {
21217 if(game->lvlitems[dlevel]&liBOSSKEY)
21218 {
21219 putdoor(scrollbuf,0,up,dOPENBOSS);
21220 tmpscr->door[0]=dOPENBOSS;
21221 setmapflag(si, mDOOR_UP);
21222
21223 if(di != 0xFFFF)
21224 setmapflag(di, mDOOR_DOWN);
21225 sfx(WAV_DOOR);
21226 markBmap(-1);
21227 // Run Boss Key Script
21228 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21229 for ( int32_t q = 0; q < MAXITEMS; ++q )
21230 {
21231 if ( itemsbuf[q].family == itype_bosskey )
21232 {
21233 key_item = q; break;
21234 }
21235 }
21236 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21237 {
21238 int i = key_item;
21239 FFCore.reset_script_engine_data(ScriptType::Item, i);
21240 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21241 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21242 }
21243 }
21244 else return;
21245
21246 }
21247
21248 }
21249 }
21250 //Down
21251 if ( y >= 128 && x >= 112 && x <= 128 )
21252 {
21253 if ( dir == down || dir == l_down || dir == r_down ) //|| Down() || ( Down()&&Left()) || ( Down()&&Right()))
21254 {
21255 di = nextscr(down);
21256 if(tmpscr->door[1]==dLOCKED)
21257 {
21258 if(usekey())
21259 {
21260 putdoor(scrollbuf,0,down,dUNLOCKED);
21261 tmpscr->door[1]=dUNLOCKED;
21262 setmapflag(si, mDOOR_DOWN);
21263
21264 if(di != 0xFFFF)
21265 setmapflag(di, mDOOR_UP);
21266 sfx(WAV_DOOR);
21267 markBmap(-1);
21268 }
21269 else return;
21270 }
21271 else if(tmpscr->door[1]==dBOSS)
21272 {
21273 if(game->lvlitems[dlevel]&liBOSSKEY)
21274 {
21275 putdoor(scrollbuf,0,down,dOPENBOSS);
21276 tmpscr->door[1]=dOPENBOSS;
21277 setmapflag(si, mDOOR_DOWN);
21278
21279 if(di != 0xFFFF)
21280 setmapflag(di, mDOOR_UP);
21281 sfx(WAV_DOOR);
21282 markBmap(-1);
21283 // Run Boss Key Script
21284 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21285 for ( int32_t q = 0; q < MAXITEMS; ++q )
21286 {
21287 if ( itemsbuf[q].family == itype_bosskey )
21288 {
21289 key_item = q; break;
21290 }
21291 }
21292 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21293 {
21294 int i = key_item;
21295 FFCore.reset_script_engine_data(ScriptType::Item, i);
21296 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21297 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21298 }
21299 }
21300 else return;
21301 }
21302 }
21303 }
21304 //left
21305 if ( y > 72 && y < 88 && x <= 32 )
21306 {
21307 if ( dir == left || dir == l_up || dir == l_down )//|| Left() || ( Up()&&Left()) || ( Down()&&Left() ) )
21308 {
21309 di = nextscr(left);
21310 if(tmpscr->door[2]==dLOCKED)
21311 {
21312 if(usekey())
21313 {
21314 putdoor(scrollbuf,0,left,dUNLOCKED);
21315 tmpscr->door[2]=dUNLOCKED;
21316 setmapflag(si, mDOOR_LEFT);
21317
21318 if(di != 0xFFFF)
21319 setmapflag(di, mDOOR_RIGHT);
21320 sfx(WAV_DOOR);
21321 markBmap(-1);
21322 }
21323 else return;
21324 }
21325 else if(tmpscr->door[2]==dBOSS)
21326 {
21327 if(game->lvlitems[dlevel]&liBOSSKEY)
21328 {
21329 putdoor(scrollbuf,0,left,dOPENBOSS);
21330 tmpscr->door[2]=dOPENBOSS;
21331 setmapflag(si, mDOOR_LEFT);
21332
21333 if(di != 0xFFFF)
21334 setmapflag(di, mDOOR_RIGHT);
21335 sfx(WAV_DOOR);
21336 markBmap(-1);
21337 // Run Boss Key Script
21338 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21339 for ( int32_t q = 0; q < MAXITEMS; ++q )
21340 {
21341 if ( itemsbuf[q].family == itype_bosskey )
21342 {
21343 key_item = q; break;
21344 }
21345 }
21346 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21347 {
21348 int i = key_item;
21349 FFCore.reset_script_engine_data(ScriptType::Item, i);
21350 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21351 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21352 }
21353 }
21354 else return;
21355 }
21356 }
21357 }
21358
21359
21360 //right
21361 if ( ( y > 72 && y < 88 ) && x >= 208 )
21362 //!( (y<=72||y>=88) && x<206 ) )
21363 //y<=72||y>=88):y!=80) || x<208)
21364 {
21365 if ( dir == right || dir == r_up || dir == r_down ) //|| Right() || ( Down()&&Right() ) || ( Up()&&Right()))
21366 {
21367 di = nextscr(right);
21368 if(tmpscr->door[right]==dLOCKED)
21369 {
21370 if(usekey())
21371 {
21372 putdoor(scrollbuf,0,right,dUNLOCKED);
21373 tmpscr->door[3]=dUNLOCKED;
21374 setmapflag(si, mDOOR_RIGHT);
21375
21376 if(di != 0xFFFF)
21377 setmapflag(di, mDOOR_LEFT);
21378 sfx(WAV_DOOR);
21379 markBmap(-1);
21380 }
21381 else return;
21382 }
21383 else if(tmpscr->door[right]==dBOSS)
21384 {
21385 if(game->lvlitems[dlevel]&liBOSSKEY)
21386 {
21387 putdoor(scrollbuf,0,right,dOPENBOSS);
21388 tmpscr->door[3]=dOPENBOSS;
21389 setmapflag(si, mDOOR_RIGHT);
21390
21391 if(di != 0xFFFF)
21392 setmapflag(di, mDOOR_LEFT);
21393 sfx(WAV_DOOR);
21394 markBmap(-1);
21395 // Run Boss Key Script
21396 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21397 for ( int32_t q = 0; q < MAXITEMS; ++q )
21398 {
21399 if ( itemsbuf[q].family == itype_bosskey )
21400 {
21401 key_item = q; break;
21402 }
21403 }
21404 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21405 {
21406 int i = key_item;
21407 FFCore.reset_script_engine_data(ScriptType::Item, i);
21408 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21409 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21410 }
21411 }
21412 else return;
21413 }
21414
21415 }
21416 }
21417 }
21418 else
21419 {
21420 //orthogonal movement
21421 //Up door
21422
4/4
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 746 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 118 times.
943 if ( y<=32 && x == 120 )
21423 //!( y>32 && (x!=120) ))
21424 {
21425
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 1 times.
118 switch ( dir )
21426 {
21427 case up:
21428 case r_up:
21429 case l_up:
21430 {
21431 117 di = nextscr(up);
21432
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 26 times.
117 if(tmpscr->door[0]==dLOCKED)
21433 {
21434
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 3 times.
91 if(usekey())
21435 {
21436 88 putdoor(scrollbuf,0,up,dUNLOCKED);
21437 88 tmpscr->door[0]=dUNLOCKED;
21438 88 setmapflag(si, mDOOR_UP);
21439
21440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(di != 0xFFFF)
21441 88 setmapflag(di, mDOOR_DOWN);
21442 88 sfx(WAV_DOOR);
21443 88 markBmap(-1);
21444 88 }
21445 3 else return;
21446 88 }
21447
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 15 times.
26 else if(tmpscr->door[0]==dBOSS)
21448 {
21449
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if(game->lvlitems[dlevel]&liBOSSKEY)
21450 {
21451 14 putdoor(scrollbuf,0,up,dOPENBOSS);
21452 14 tmpscr->door[0]=dOPENBOSS;
21453 14 setmapflag(si, mDOOR_UP);
21454
21455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(di != 0xFFFF)
21456 14 setmapflag(di, mDOOR_DOWN);
21457 14 sfx(WAV_DOOR);
21458 14 markBmap(-1);
21459 // Run Boss Key Script
21460 14 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 for ( int32_t q = 0; q < MAXITEMS; ++q )
21462 {
21463
2/2
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
952 if ( itemsbuf[q].family == itype_bosskey )
21464 {
21465 14 key_item = q; break;
21466 }
21467 938 }
21468
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21469 {
21470 int i = key_item;
21471 FFCore.reset_script_engine_data(ScriptType::Item, i);
21472 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21473 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21474 }
21475 14 }
21476 1 else return;
21477 14 }
21478 113 break;
21479 }
21480 1 default: break;
21481
21482 }
21483 114 }
21484 //Down
21485
4/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 820 times.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 38 times.
939 if ( y >= 128 && x == 120 )
21486 //!(y<128 && (x!=120) ) )
21487 {
21488
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 3 times.
38 switch(dir)
21489 {
21490 case down:
21491 case l_down:
21492 case r_down:
21493 {
21494 35 di = nextscr(down);
21495
21496
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 11 times.
35 if(tmpscr->door[1]==dLOCKED)
21497 {
21498
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if(usekey())
21499 {
21500 23 putdoor(scrollbuf,0,down,dUNLOCKED);
21501 23 tmpscr->door[1]=dUNLOCKED;
21502 23 setmapflag(si, mDOOR_DOWN);
21503
21504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(di != 0xFFFF)
21505 23 setmapflag(di, mDOOR_UP);
21506 23 sfx(WAV_DOOR);
21507 23 markBmap(-1);
21508 23 }
21509 1 else return;
21510 23 }
21511
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 else if(tmpscr->door[1]==dBOSS)
21512 {
21513
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
21514 {
21515 4 putdoor(scrollbuf,0,down,dOPENBOSS);
21516 4 tmpscr->door[1]=dOPENBOSS;
21517 4 setmapflag(si, mDOOR_DOWN);
21518
21519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
21520 4 setmapflag(di, mDOOR_UP);
21521 4 sfx(WAV_DOOR);
21522 4 markBmap(-1);
21523 // Run Boss Key Script
21524 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
21526 {
21527
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
21528 {
21529 4 key_item = q; break;
21530 }
21531 268 }
21532
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21533 {
21534 int i = key_item;
21535 FFCore.reset_script_engine_data(ScriptType::Item, i);
21536 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21537 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21538 }
21539 4 }
21540 1 else return;
21541 4 }
21542 33 break;
21543 }
21544 3 default: break;
21545 }
21546 36 }
21547 //left
21548
4/4
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 749 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 58 times.
937 if ( y == 80 && x <= 32 )
21549 //!( (y!=80) && x>32 ) )
21550 {
21551
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 9 times.
58 switch(dir)
21552 {
21553 case left:
21554 case l_up:
21555 case l_down:
21556 {
21557 49 di = nextscr(left);
21558
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 14 times.
49 if(tmpscr->door[2]==dLOCKED)
21559 {
21560
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2 times.
35 if(usekey())
21561 {
21562 33 putdoor(scrollbuf,0,left,dUNLOCKED);
21563 33 tmpscr->door[2]=dUNLOCKED;
21564 33 setmapflag(si, mDOOR_LEFT);
21565
21566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(di != 0xFFFF)
21567 33 setmapflag(di, mDOOR_RIGHT);
21568 33 sfx(WAV_DOOR);
21569 33 markBmap(-1);
21570 33 }
21571 2 else return;
21572 33 }
21573
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
14 else if(tmpscr->door[2]==dBOSS)
21574 {
21575
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
21576 {
21577 4 putdoor(scrollbuf,0,left,dOPENBOSS);
21578 4 tmpscr->door[2]=dOPENBOSS;
21579 4 setmapflag(si, mDOOR_LEFT);
21580
21581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
21582 4 setmapflag(di, mDOOR_RIGHT);
21583 4 sfx(WAV_DOOR);
21584 4 markBmap(-1);
21585 // Run Boss Key Script
21586 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
21588 {
21589
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
21590 {
21591 4 key_item = q; break;
21592 }
21593 268 }
21594
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21595 {
21596 int i = key_item;
21597 FFCore.reset_script_engine_data(ScriptType::Item, i);
21598 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21599 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21600 }
21601 4 }
21602 1 else return;
21603 4 }
21604
21605 46 break;
21606
21607 }
21608 9 default: break;
21609 }
21610 55 }
21611 //right
21612
4/4
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 749 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 73 times.
934 if ( y == 80 && x >= 208 )
21613 //!((y!=80) && x<208 ) )
21614 {
21615
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 4 times.
73 switch(dir)
21616 {
21617 case right:
21618 case r_down:
21619 case r_up:
21620 {
21621 69 di = nextscr(right);
21622
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 19 times.
69 if(tmpscr->door[3]==dLOCKED)
21623 {
21624
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 4 times.
50 if(usekey())
21625 {
21626 46 putdoor(scrollbuf,0,right,dUNLOCKED);
21627 46 tmpscr->door[3]=dUNLOCKED;
21628 46 setmapflag(si, mDOOR_RIGHT);
21629
21630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(di != 0xFFFF)
21631 46 setmapflag(di, mDOOR_LEFT);
21632 46 sfx(WAV_DOOR);
21633 46 markBmap(-1);
21634 46 }
21635 4 else return;
21636 46 }
21637
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 8 times.
19 else if(tmpscr->door[3]==dBOSS)
21638 {
21639
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(game->lvlitems[dlevel]&liBOSSKEY)
21640 {
21641 7 putdoor(scrollbuf,0,right,dOPENBOSS);
21642 7 tmpscr->door[3]=dOPENBOSS;
21643 7 setmapflag(si, mDOOR_RIGHT);
21644
21645
21646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(di != 0xFFFF)
21647 7 setmapflag(di, mDOOR_LEFT);
21648 7 sfx(WAV_DOOR);
21649 7 markBmap(-1);
21650 // Run Boss Key Script
21651 7 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 for ( int32_t q = 0; q < MAXITEMS; ++q )
21653 {
21654
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 7 times.
476 if ( itemsbuf[q].family == itype_bosskey )
21655 {
21656 7 key_item = q; break;
21657 }
21658 469 }
21659
2/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //
21660 {
21661 int i = key_item;
21662 FFCore.reset_script_engine_data(ScriptType::Item, i);
21663 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21664 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21665 }
21666
21667 7 }
21668 1 else return;
21669 7 }
21670
21671
21672 64 break;
21673 }
21674 4 default: break;
21675
21676 }
21677 68 }
21678 }
21679 6395885 }
21680
21681 6395885 void HeroClass::checkswordtap()
21682 {
21683
6/6
✓ Branch 0 taken 3025085 times.
✓ Branch 1 taken 3370800 times.
✓ Branch 2 taken 1913 times.
✓ Branch 3 taken 3023172 times.
✓ Branch 4 taken 1902 times.
✓ Branch 5 taken 11 times.
6395885 if(attack!=wSword || charging<=0 || pushing<8) return;
21684
21685 11 int32_t bx=x;
21686 11 int32_t by=y+8;
21687
21688
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
11 switch(dir)
21689 {
21690 case up:
21691
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!Up()) return;
21692
21693 11 by-=16;
21694 11 break;
21695
21696 case down:
21697 if(!Down()) return;
21698
21699 by+=16;
21700 bx+=8;
21701 break;
21702
21703 case left:
21704 if(!Left()) return;
21705
21706 bx-=16;
21707 by+=8;
21708 break;
21709
21710 case right:
21711 if(!Right()) return;
21712
21713 bx+=16;
21714 by+=8;
21715 break;
21716 }
21717
21718
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
11 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
21719
21720 11 attackclk=SWORDTAPFRAME;
21721 11 pushing=-8; //16 frames between taps
21722 11 tapping=true;
21723
21724 11 int32_t type = COMBOTYPE(bx,by);
21725
21726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!isCuttableType(type))
21727 {
21728
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
22 bool hollow = (MAPFLAG(bx,by) == mfBOMB || MAPCOMBOFLAG(bx,by) == mfBOMB ||
21729
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 MAPFLAG(bx,by) == mfSBOMB || MAPCOMBOFLAG(bx,by) == mfSBOMB);
21730
21731 // Layers
21732
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11 times.
77 for(int32_t i=0; i < 6; i++)
21733
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
132 hollow = (hollow || MAPFLAG2(i,bx,by) == mfBOMB || MAPCOMBOFLAG2(i,bx,by) == mfBOMB ||
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 MAPFLAG2(i,bx,by) == mfSBOMB || MAPCOMBOFLAG2(i,bx,by) == mfSBOMB);
21735
21736
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
21737
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if(tmpscr->door[i]==dBOMB && i==dir)
21738 switch(i)
21739 {
21740 case up:
21741 case down:
21742 if(bx>=112 && bx<144 && (by>=144 || by<=32)) hollow=true;
21743
21744 break;
21745
21746 case left:
21747 case right:
21748 if(by>=72 && by<104 && (bx>=224 || bx<=32)) hollow=true;
21749
21750 break;
21751 }
21752
21753 11 sfx(hollow ? WAV_ZN1TAP2 : WAV_ZN1TAP,pan(x.getInt()));
21754 11 }
21755
21756 6395885 }
21757
21758 19620 void HeroClass::fairycircle(int32_t type)
21759 {
21760
2/2
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 3259 times.
19620 if(fairyclk==0)
21761 {
21762
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3259 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3259 switch(type)
21763 {
21764 case REFILL_LIFE:
21765
2/2
✓ Branch 0 taken 3156 times.
✓ Branch 1 taken 103 times.
3259 if(didstuff&did_fairy) return;
21766
21767 103 didstuff|=did_fairy;
21768 103 break;
21769
21770 case REFILL_MAGIC:
21771 if(didstuff&did_magic) return;
21772
21773 didstuff|=did_magic;
21774 break;
21775
21776 case REFILL_ALL:
21777 if(didstuff&did_all) return;
21778
21779 didstuff|=did_all;
21780 }
21781
21782 103 refill_what=type;
21783 103 refill_why=REFILL_FAIRY;
21784 103 StartRefill(type);
21785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
21786 103 else {action=freeze; FFCore.setHeroAction(freeze);}
21787 103 holdclk=0;
21788 103 hopclk=0;
21789 103 }
21790
21791 16464 ++fairyclk;
21792
21793
2/2
✓ Branch 0 taken 8121 times.
✓ Branch 1 taken 8343 times.
16464 if(refilling!=REFILL_FAIRYDONE)
21794 {
21795
2/2
✓ Branch 0 taken 8018 times.
✓ Branch 1 taken 103 times.
8121 if(!refill())
21796 103 refilling=REFILL_FAIRYDONE;
21797 8121 }
21798
21799
2/2
✓ Branch 0 taken 8240 times.
✓ Branch 1 taken 103 times.
8343 else if(++holdclk>80)
21800 {
21801 103 reset_swordcharge();
21802 103 attackclk=0;
21803 103 action=none; FFCore.setHeroAction(none);
21804 103 fairyclk=0;
21805 103 holdclk=0;
21806 103 refill_why = 0;
21807 103 refilling=REFILL_NONE;
21808 103 map_bkgsfx(true);
21809 103 }
21810 19620 }
21811
21812 642685 int32_t touchcombo(int32_t x,int32_t y)
21813 {
21814
2/2
✓ Branch 0 taken 1285370 times.
✓ Branch 1 taken 642685 times.
1928055 for (int32_t i = 0; i <= 1; ++i)
21815 {
21816
2/2
✓ Branch 0 taken 1080322 times.
✓ Branch 1 taken 205048 times.
1285370 if(tmpscr2[i].valid!=0)
21817 {
21818
2/2
✓ Branch 0 taken 197733 times.
✓ Branch 1 taken 7315 times.
205048 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
21819 {
21820
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 197733 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
197733 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
21821 197733 }
21822 else
21823 {
21824
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7315 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7315 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
21825 }
21826 205048 }
21827 1285370 }
21828
2/2
✓ Branch 0 taken 641271 times.
✓ Branch 1 taken 1414 times.
642685 if (!_effectflag(x,y,1, -1)) return 0;
21829 641271 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
21830
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 641223 times.
641271 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
21831 48 return 0;
21832
3/3
✓ Branch 0 taken 2842 times.
✓ Branch 1 taken 636762 times.
✓ Branch 2 taken 1619 times.
641223 switch(cmb.type)
21833 {
21834 case cBSGRAVE:
21835 case cGRAVE:
21836
3/4
✓ Branch 0 taken 1913 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 1913 times.
✗ Branch 3 not taken.
2842 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
21837 {
21838 929 break;
21839 }
21840
21841 [[fallthrough]];
21842 case cARMOS:
21843 {
21844 3532 return cmb.type;
21845 }
21846 }
21847
21848 637691 return 0;
21849 642685 }
21850
21851 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
21852 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
21853
21854 static int32_t GridX(int32_t x)
21855 {
21856 return (x >> 4) << 4;
21857 }
21858
21859 //Snaps 'y' to the combo grid
21860 //Equivalent to calling ComboY(ComboAt(foo,y));
21861 static int32_t GridY(int32_t y)
21862 {
21863 return (y >> 4) << 4;
21864 }
21865
21866 30 int32_t grabComboFromPos(int32_t pos, int32_t type)
21867 {
21868
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 for(int32_t lyr = 6; lyr > -1; --lyr)
21869 {
21870 210 int32_t id = FFCore.tempScreens[lyr]->data[pos];
21871
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 180 times.
210 if(combobuf[id].type == type)
21872 30 return id;
21873 180 }
21874 return -1;
21875 30 }
21876
21877 static int32_t typeMap[176];
21878 static int32_t istrig[176];
21879 static const int32_t SPTYPE_SOLID = -1;
21880 #define SP_VISITED 0x1
21881 #define SPFLAG(dir) (0x2<<dir)
21882 #define BEAM_AGE_LIMIT 32
21883 1234 void HeroClass::handleBeam(byte* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
21884 {
21885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = set ? (1 << (set-1)) : ~0;
21886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(spotdir > 3) return; //invalid dir
21887 1234 bool doAge = true;
21888 1234 byte f = 0;
21889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13668 times.
13668 while(unsigned(curpos) < 176)
21890 {
21891 13668 bool block_light = false;
21892 13668 f = SPFLAG(spotdir);
21893
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 13341 times.
13668 if((grid[curpos] & f) != f)
21894 {
21895 13341 grid[curpos] |= f;
21896 13341 istrig[curpos] |= trigflag;
21897 13341 doAge = false;
21898 13341 age = 0;
21899 13341 }
21900
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 652 times.
✓ Branch 3 taken 12657 times.
✓ Branch 4 taken 183 times.
13668 switch(spotdir)
21901 {
21902 case up:
21903 176 curpos -= 0x10;
21904 176 break;
21905 case down:
21906 652 curpos += 0x10;
21907 652 break;
21908 case left:
21909
1/2
✓ Branch 0 taken 12657 times.
✗ Branch 1 not taken.
12657 if(!(curpos%0x10))
21910 curpos = -1;
21911 12657 else --curpos;
21912 12657 break;
21913 case right:
21914 183 ++curpos;
21915
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 if(!(curpos%0x10))
21916 curpos = -1;
21917 183 break;
21918 }
21919
1/2
✓ Branch 0 taken 13668 times.
✗ Branch 1 not taken.
13668 if(unsigned(curpos) >= 176) break;
21920
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 12440 times.
13668 switch(typeMap[curpos])
21921 {
21922 case SPTYPE_SOLID: case cBLOCKALL:
21923 1228 curpos = -1;
21924 1228 break;
21925 }
21926
3/6
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 13371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13668 if((curpos==COMBOPOS(x.getInt()+8,y.getInt()+8)) && block && (spotdir == oppositeDir[dir]))
21927 curpos = -1;
21928
2/2
✓ Branch 0 taken 12440 times.
✓ Branch 1 taken 1228 times.
13668 if(unsigned(curpos) >= 176) break;
21929
21930 12440 f = SPFLAG(oppositeDir[spotdir]);
21931
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 12113 times.
12440 if((grid[curpos] & f) != f)
21932 {
21933 12113 grid[curpos] |= f;
21934 12113 istrig[curpos] |= trigflag;
21935 12113 doAge = false;
21936 12113 age = 0;
21937 12113 }
21938
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 12113 times.
12440 if(doAge)
21939 {
21940
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 6 times.
327 if(++age > BEAM_AGE_LIMIT)
21941 6 break;
21942 321 }
21943 12113 else doAge = true;
21944
21945
3/4
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 12137 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
12434 if(curpos==COMBOPOS(x.getInt()+8,y.getInt() +8) && refl)
21946 297 spotdir = dir;
21947
2/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 12107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
12137 else switch(typeMap[curpos])
21948 {
21949 case cLIGHTTARGET:
21950
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(combobuf[grabComboFromPos(curpos, cLIGHTTARGET)].usrflags&cflag3) //Blocks light
21951 return;
21952 case cMIRROR:
21953 30 spotdir = oppositeDir[spotdir];
21954 30 break;
21955 case cMIRRORSLASH:
21956 switch(spotdir)
21957 {
21958 case up:
21959 spotdir = right; break;
21960 case right:
21961 spotdir = up; break;
21962 case down:
21963 spotdir = left; break;
21964 case left:
21965 spotdir = down; break;
21966 }
21967 break;
21968 case cMIRRORBACKSLASH:
21969 switch(spotdir)
21970 {
21971 case up:
21972 spotdir = left; break;
21973 case left:
21974 spotdir = up; break;
21975 case down:
21976 spotdir = right; break;
21977 case right:
21978 spotdir = down; break;
21979 }
21980 break;
21981 case cMAGICPRISM:
21982 for(byte d = 0; d < 4; ++d)
21983 {
21984 if(d == oppositeDir[spotdir]) continue;
21985 handleBeam(grid, age, d, curpos, set, block, refl);
21986 }
21987 return;
21988 case cMAGICPRISM4:
21989 for(byte d = 0; d < 4; ++d)
21990 {
21991 handleBeam(grid, age, d, curpos, set, block, refl);
21992 }
21993 return;
21994 }
21995 }
21996 1234 }
21997
21998 6406142 void HeroClass::handleSpotlights()
21999 {
22000 typedef byte spot_t;
22001 //Store each different tile/color as grids
22002 6406142 std::map<int32_t, spot_t*> maps;
22003
1/2
✓ Branch 0 taken 6406142 times.
✗ Branch 1 not taken.
6406142 int32_t shieldid = getCurrentShield(false);
22004
2/2
✓ Branch 0 taken 5864117 times.
✓ Branch 1 taken 542025 times.
6406142 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
22005
4/4
✓ Branch 0 taken 6396052 times.
✓ Branch 1 taken 10090 times.
✓ Branch 2 taken 542025 times.
✓ Branch 3 taken 5854027 times.
6406142 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
22006
3/6
✓ Branch 0 taken 6406142 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6406142 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6406142 times.
✗ Branch 5 not taken.
6406142 int32_t heropos = COMBOPOS(x.getInt()+8,y.getInt()+8);
22007 6406142 memset(istrig, 0, sizeof(istrig));
22008
1/2
✓ Branch 0 taken 6406142 times.
✗ Branch 1 not taken.
6406142 clear_bitmap(lightbeam_bmp);
22009
22010
2/2
✓ Branch 0 taken 1127480992 times.
✓ Branch 1 taken 6406142 times.
1133887134 for(size_t pos = 0; pos < 176; ++pos)
22011 {
22012 1127480992 typeMap[pos] = 0;
22013
2/2
✓ Branch 0 taken 1127267516 times.
✓ Branch 1 taken 7892326336 times.
9019593852 for(int32_t lyr = 6; lyr > -1; --lyr)
22014 {
22015 7892326336 newcombo const* cmb = &combobuf[FFCore.tempScreens[lyr]->data[pos]];
22016
3/3
✓ Branch 0 taken 209774 times.
✓ Branch 1 taken 7892112860 times.
✓ Branch 2 taken 3702 times.
7892326336 switch(cmb->type)
22017 {
22018 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
22019 case cMAGICPRISM: case cMAGICPRISM4:
22020 case cBLOCKALL: case cLIGHTTARGET:
22021 209774 typeMap[pos] = cmb->type;
22022 209774 break;
22023 case cGLASS:
22024 3702 typeMap[pos] = 0;
22025 3702 break;
22026 default:
22027 {
22028
4/4
✓ Branch 0 taken 3382188892 times.
✓ Branch 1 taken 4509923968 times.
✓ Branch 2 taken 2700899649 times.
✓ Branch 3 taken 681289243 times.
7892112860 if(lyr < 3 && (cmb->walk & 0xF))
22029 {
22030 681289243 typeMap[pos] = SPTYPE_SOLID;
22031 681289243 }
22032 7892112860 continue; //next layer
22033 }
22034 }
22035 213476 break; //hit a combo type
22036 }
22037 1127480992 }
22038
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 6405895 times.
6406142 if(unsigned(heropos) < 176)
22039 {
22040
2/2
✓ Branch 0 taken 627555 times.
✓ Branch 1 taken 5778340 times.
6405895 switch(typeMap[heropos])
22041 {
22042 case SPTYPE_SOLID: case cBLOCKALL:
22043 627555 heropos = -1; //Blocked from hitting player
22044 627555 }
22045 6405895 }
22046
22047
2/2
✓ Branch 0 taken 44842994 times.
✓ Branch 1 taken 6406142 times.
51249136 for(size_t layer = 0; layer < 7; ++layer)
22048 {
22049 44842994 mapscr* curlayer = FFCore.tempScreens[layer];
22050
2/2
✓ Branch 0 taken 7892366944 times.
✓ Branch 1 taken 44842994 times.
7937209938 for(size_t pos = 0; pos < 176; ++pos)
22051 {
22052 //For each spotlight combo on each layer...
22053 7892366944 newcombo const& cmb = combobuf[curlayer->data[pos]];
22054
2/2
✓ Branch 0 taken 7892365710 times.
✓ Branch 1 taken 1234 times.
7892366944 if(cmb.type == cSPOTLIGHT)
22055 {
22056 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
22057
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
2468 int32_t id = (cmb.usrflags&cflag1)
22058
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 ? std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24
22059 : -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
22060
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(!id) continue;
22061 // zprint2("ID = %ld\n", id);
22062 //Get the grid array for this tile/color
22063 spot_t* grid;
22064
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1234 times.
1234 if(maps[id])
22065 grid = maps[id];
22066 else
22067 {
22068
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 grid = new spot_t[176];
22069 1234 memset(grid, 0, sizeof(spot_t)*176);
22070
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 maps[id] = grid;
22071 }
22072 1234 byte spotdir = cmb.attribytes[0];
22073 1234 int32_t curpos = pos;
22074
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(spotdir > 3)
22075 {
22076 grid[curpos] |= SP_VISITED;
22077 istrig[curpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
22078 }
22079
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1234 times.
✗ Branch 3 not taken.
1234 if(refl && curpos == heropos)
22080 {
22081 spotdir = dir;
22082 }
22083
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 handleBeam(grid, 0, spotdir, curpos, cmb.attribytes[4], block, refl);
22084 1234 }
22085 7892366944 }
22086 44842994 }
22087
22088 6406142 lightbeam_present = !maps.empty();
22089
22090 //Draw visuals
22091
2/2
✓ Branch 0 taken 6406142 times.
✓ Branch 1 taken 1234 times.
6407376 for(auto it = maps.begin(); it != maps.end();)
22092 {
22093 1234 int32_t id = it->first;
22094 1234 spot_t* grid = it->second;
22095 //
22096 enum {t_gr, t_up, t_down, t_left, t_right, t_uleft, t_uright, t_dleft, t_dright, t_vert, t_horz, t_notup, t_notdown, t_notleft, t_notright, t_all, t_max };
22097 1234 int32_t tile = (id&0xFFFFFF);
22098 1234 int32_t cs = (id>>24);
22099 1234 byte c_inner = ((-id)&0x0000FF);
22100 1234 byte c_middle = ((-id)&0x00FF00)>>8;
22101 1234 byte c_outter = ((-id)&0xFF0000)>>16;
22102 //{ Setup color bitmap
22103 1234 BITMAP* cbmp = NULL;
22104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(id < 0)
22105 {
22106 //zprint2("Creating with colors: %02X,%02X,%02X\n", c_inner, c_middle, c_outter);
22107 cbmp = create_bitmap_ex(8, 16*t_max, 16);
22108 clear_bitmap(cbmp);
22109 for(size_t q = 1; q < t_max; ++q)
22110 {
22111 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
22112 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
22113 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
22114 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
22115 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
22116 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
22117 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
22118 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
22119 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
22120 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
22121 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
22122 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
22123 }
22124 //t_gr
22125 circlefill(cbmp, 16*t_gr+8, 8, 7, c_outter);
22126 circlefill(cbmp, 16*t_gr+7, 8, 7, c_outter);
22127 circlefill(cbmp, 16*t_gr+8, 7, 7, c_outter);
22128 circlefill(cbmp, 16*t_gr+7, 7, 7, c_outter);
22129 circlefill(cbmp, 16*t_gr+8, 8, 5, c_middle);
22130 circlefill(cbmp, 16*t_gr+7, 8, 5, c_middle);
22131 circlefill(cbmp, 16*t_gr+8, 7, 5, c_middle);
22132 circlefill(cbmp, 16*t_gr+7, 7, 5, c_middle);
22133 circlefill(cbmp, 16*t_gr+8, 8, 3, c_inner);
22134 circlefill(cbmp, 16*t_gr+7, 8, 3, c_inner);
22135 circlefill(cbmp, 16*t_gr+8, 7, 3, c_inner);
22136 circlefill(cbmp, 16*t_gr+7, 7, 3, c_inner);
22137 //t_up
22138 rectfill(cbmp, 16*t_up+4, 0, 16*t_up+11, 7, c_outter);
22139 rectfill(cbmp, 16*t_up+6, 0, 16*t_up+9, 7, c_middle);
22140 rectfill(cbmp, 16*t_up+7, 0, 16*t_up+8, 7, c_inner);
22141 //t_down
22142 rectfill(cbmp, 16*t_down+4, 8, 16*t_down+11, 15, c_outter);
22143 rectfill(cbmp, 16*t_down+6, 8, 16*t_down+9, 15, c_middle);
22144 rectfill(cbmp, 16*t_down+7, 8, 16*t_down+8, 15, c_inner);
22145 //t_left
22146 rectfill(cbmp, 16*t_left, 4, 16*t_left+7, 11, c_outter);
22147 rectfill(cbmp, 16*t_left, 6, 16*t_left+7, 9, c_middle);
22148 rectfill(cbmp, 16*t_left, 7, 16*t_left+7, 8, c_inner);
22149 //t_right
22150 rectfill(cbmp, 16*t_right+8, 4, 16*t_right+15, 11, c_outter);
22151 rectfill(cbmp, 16*t_right+8, 6, 16*t_right+15, 9, c_middle);
22152 rectfill(cbmp, 16*t_right+8, 7, 16*t_right+15, 8, c_inner);
22153 //t_uleft
22154 rectfill(cbmp, 16*t_uleft+4, 0, 16*t_uleft+11, 7, c_outter);
22155 rectfill(cbmp, 16*t_uleft, 4, 16*t_uleft+7, 11, c_outter);
22156 rectfill(cbmp, 16*t_uleft, 6, 16*t_uleft+7, 9, c_middle);
22157 rectfill(cbmp, 16*t_uleft+6, 0, 16*t_uleft+9, 7, c_middle);
22158 rectfill(cbmp, 16*t_uleft+7, 0, 16*t_uleft+8, 7, c_inner);
22159 rectfill(cbmp, 16*t_uleft, 7, 16*t_uleft+7, 8, c_inner);
22160 //t_uright
22161 rectfill(cbmp, 16*t_uright+4, 0, 16*t_uright+11, 7, c_outter);
22162 rectfill(cbmp, 16*t_uright+8, 4, 16*t_uright+15, 11, c_outter);
22163 rectfill(cbmp, 16*t_uright+8, 6, 16*t_uright+15, 9, c_middle);
22164 rectfill(cbmp, 16*t_uright+6, 0, 16*t_uright+9, 7, c_middle);
22165 rectfill(cbmp, 16*t_uright+7, 0, 16*t_uright+8, 7, c_inner);
22166 rectfill(cbmp, 16*t_uright+8, 7, 16*t_uright+15, 8, c_inner);
22167 //t_dleft
22168 rectfill(cbmp, 16*t_dleft+4, 8, 16*t_dleft+11, 15, c_outter);
22169 rectfill(cbmp, 16*t_dleft, 4, 16*t_dleft+7, 11, c_outter);
22170 rectfill(cbmp, 16*t_dleft, 6, 16*t_dleft+7, 9, c_middle);
22171 rectfill(cbmp, 16*t_dleft+6, 8, 16*t_dleft+9, 15, c_middle);
22172 rectfill(cbmp, 16*t_dleft+7, 8, 16*t_dleft+8, 15, c_inner);
22173 rectfill(cbmp, 16*t_dleft, 7, 16*t_dleft+7, 8, c_inner);
22174 //t_dright
22175 rectfill(cbmp, 16*t_dright+4, 8, 16*t_dright+11, 15, c_outter);
22176 rectfill(cbmp, 16*t_dright+8, 4, 16*t_dright+15, 11, c_outter);
22177 rectfill(cbmp, 16*t_dright+8, 6, 16*t_dright+15, 9, c_middle);
22178 rectfill(cbmp, 16*t_dright+6, 8, 16*t_dright+9, 15, c_middle);
22179 rectfill(cbmp, 16*t_dright+7, 8, 16*t_dright+8, 15, c_inner);
22180 rectfill(cbmp, 16*t_dright+8, 7, 16*t_dright+15, 8, c_inner);
22181 //t_vert
22182 rectfill(cbmp, 16*t_vert+4, 0, 16*t_vert+11, 15, c_outter);
22183 rectfill(cbmp, 16*t_vert+6, 0, 16*t_vert+9, 15, c_middle);
22184 rectfill(cbmp, 16*t_vert+7, 0, 16*t_vert+8, 15, c_inner);
22185 //t_horz
22186 rectfill(cbmp, 16*t_horz, 4, 16*t_horz+15, 11, c_outter);
22187 rectfill(cbmp, 16*t_horz, 6, 16*t_horz+15, 9, c_middle);
22188 rectfill(cbmp, 16*t_horz, 7, 16*t_horz+15, 8, c_inner);
22189 //t_notup
22190 rectfill(cbmp, 16*t_notup, 4, 16*t_notup+15, 11, c_outter);
22191 rectfill(cbmp, 16*t_notup+4, 8, 16*t_notup+11, 15, c_outter);
22192 rectfill(cbmp, 16*t_notup+6, 8, 16*t_notup+9, 15, c_middle);
22193 rectfill(cbmp, 16*t_notup, 6, 16*t_notup+15, 9, c_middle);
22194 rectfill(cbmp, 16*t_notup, 7, 16*t_notup+15, 8, c_inner);
22195 rectfill(cbmp, 16*t_notup+7, 8, 16*t_notup+8, 15, c_inner);
22196 //t_notdown
22197 rectfill(cbmp, 16*t_notdown, 4, 16*t_notdown+15, 11, c_outter);
22198 rectfill(cbmp, 16*t_notdown+4, 0, 16*t_notdown+11, 7, c_outter);
22199 rectfill(cbmp, 16*t_notdown+6, 0, 16*t_notdown+9, 7, c_middle);
22200 rectfill(cbmp, 16*t_notdown, 6, 16*t_notdown+15, 9, c_middle);
22201 rectfill(cbmp, 16*t_notdown, 7, 16*t_notdown+15, 8, c_inner);
22202 rectfill(cbmp, 16*t_notdown+7, 0, 16*t_notdown+8, 7, c_inner);
22203 //t_notleft
22204 rectfill(cbmp, 16*t_notleft+4, 0, 16*t_notleft+11, 15, c_outter);
22205 rectfill(cbmp, 16*t_notleft+8, 4, 16*t_notleft+15, 11, c_outter);
22206 rectfill(cbmp, 16*t_notleft+8, 6, 16*t_notleft+15, 9, c_middle);
22207 rectfill(cbmp, 16*t_notleft+6, 0, 16*t_notleft+9, 15, c_middle);
22208 rectfill(cbmp, 16*t_notleft+7, 0, 16*t_notleft+8, 15, c_inner);
22209 rectfill(cbmp, 16*t_notleft+8, 7, 16*t_notleft+15, 8, c_inner);
22210 //t_notright
22211 rectfill(cbmp, 16*t_notright+4, 0, 16*t_notright+11, 15, c_outter);
22212 rectfill(cbmp, 16*t_notright, 4, 16*t_notright+7, 11, c_outter);
22213 rectfill(cbmp, 16*t_notright, 6, 16*t_notright+7, 9, c_middle);
22214 rectfill(cbmp, 16*t_notright+6, 0, 16*t_notright+9, 15, c_middle);
22215 rectfill(cbmp, 16*t_notright+7, 0, 16*t_notright+8, 15, c_inner);
22216 rectfill(cbmp, 16*t_notright, 7, 16*t_notright+7, 8, c_inner);
22217 //t_all
22218 rectfill(cbmp, 16*t_all+4, 0, 16*t_all+11, 15, c_outter);
22219 rectfill(cbmp, 16*t_all, 4, 16*t_all+15, 11, c_outter);
22220 rectfill(cbmp, 16*t_all, 6, 16*t_all+15, 9, c_middle);
22221 rectfill(cbmp, 16*t_all+6, 0, 16*t_all+9, 15, c_middle);
22222 rectfill(cbmp, 16*t_all+7, 0, 16*t_all+8, 15, c_inner);
22223 rectfill(cbmp, 16*t_all, 7, 16*t_all+15, 8, c_inner);
22224 }
22225 //}
22226 //
22227
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 217184 times.
218418 for(size_t pos = 0; pos < 176; ++pos)
22228 {
22229 217184 int32_t offs = -1;
22230
8/17
✗ Branch 0 not taken.
✓ Branch 1 taken 203837 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1207 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 511 times.
✓ Branch 7 taken 11477 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 37 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 82 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
217184 switch(grid[pos]>>1)
22231 {
22232 203837 case 0: default:
22233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203837 times.
203837 if(grid[pos])
22234 {
22235 offs = t_gr;
22236 break;
22237 }
22238 203837 continue; //no draw this pos
22239 case 0b0001:
22240 6 offs = t_up;
22241 6 break;
22242 case 0b0010:
22243 offs = t_down;
22244 break;
22245 case 0b0100:
22246 1207 offs = t_left;
22247 1207 break;
22248 case 0b1000:
22249 27 offs = t_right;
22250 27 break;
22251 case 0b0011:
22252 511 offs = t_vert;
22253 511 break;
22254 case 0b1100:
22255 11477 offs = t_horz;
22256 11477 break;
22257 case 0b0101:
22258 offs = t_uleft;
22259 break;
22260 case 0b1001:
22261 37 offs = t_uright;
22262 37 break;
22263 case 0b0110:
22264 offs = t_dleft;
22265 break;
22266 case 0b1010:
22267 82 offs = t_dright;
22268 82 break;
22269 case 0b1110:
22270 offs = t_notup;
22271 break;
22272 case 0b1101:
22273 offs = t_notdown;
22274 break;
22275 case 0b1011:
22276 offs = t_notleft;
22277 break;
22278 case 0b0111:
22279 offs = t_notright;
22280 break;
22281 case 0b1111:
22282 offs = t_all;
22283 break;
22284 }
22285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13347 times.
13347 if(id > 0) //tile
22286 {
22287 //Draw 'tile' at 'pos'
22288
3/6
✓ Branch 0 taken 13347 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13347 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13347 times.
✗ Branch 5 not taken.
13347 overtile16(lightbeam_bmp, tile+offs, COMBOX(pos), COMBOY(pos), cs, 0);
22289 13347 }
22290 else //colors
22291 {
22292 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
22293 }
22294 13347 }
22295 //
22296
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1234 if(cbmp) destroy_bitmap(cbmp);
22297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 delete[] it->second;
22298
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 it = maps.erase(it);
22299 }
22300 //Check triggers
22301 6406142 bool hastrigs = false, istrigged = true;
22302
1/2
✓ Branch 0 taken 6406142 times.
✗ Branch 1 not taken.
6406142 bool alltrig = getmapflag(mLIGHTBEAM);
22303
2/2
✓ Branch 0 taken 44842994 times.
✓ Branch 1 taken 6406142 times.
51249136 for(size_t layer = 0; layer < 7; ++layer)
22304 {
22305 44842994 mapscr* curlayer = FFCore.tempScreens[layer];
22306
2/2
✓ Branch 0 taken 7892366944 times.
✓ Branch 1 taken 44842994 times.
7937209938 for(size_t pos = 0; pos < 176; ++pos)
22307 {
22308 7892366944 newcombo const* cmb = &combobuf[curlayer->data[pos]];
22309
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 7892365710 times.
7892366944 if(cmb->type == cLIGHTTARGET)
22310 {
22311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
22312 1234 hastrigs = true;
22313 1234 bool trigged = (istrig[pos]&trigflag);
22314
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
22315 trigged = !trigged;
22316
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 985 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
22317 {
22318
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
22319 {
22320 curlayer->data[pos] -= 1;
22321 istrigged = false;
22322 }
22323 249 }
22324 else //Unsolved version
22325 {
22326
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
22327 1 curlayer->data[pos] += 1;
22328 984 else istrigged = false;
22329 }
22330 1234 }
22331
2/2
✓ Branch 0 taken 7892362008 times.
✓ Branch 1 taken 3702 times.
7892365710 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
22332 {
22333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
22334 3702 bool trigged = (istrig[pos]&trigflag);
22335
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 3597 times.
✓ Branch 2 taken 3696 times.
✓ Branch 3 taken 6 times.
3702 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
22336 3597 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
22337 {
22338
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 do_trigger_combo(layer, pos);
22339 6 }
22340 3702 }
22341 7892366944 }
22342 44842994 }
22343
1/2
✓ Branch 0 taken 6406142 times.
✗ Branch 1 not taken.
6406142 word c = tmpscr->numFFC();
22344
2/2
✓ Branch 0 taken 6406142 times.
✓ Branch 1 taken 200960076 times.
207366218 for(word i=0; i<c; i++)
22345 {
22346 200960076 ffcdata& ffc = tmpscr->ffcs[i];
22347
1/2
✓ Branch 0 taken 200960076 times.
✗ Branch 1 not taken.
200960076 newcombo const* cmb = &combobuf[ffc.getData()];
22348
7/14
✓ Branch 0 taken 200960076 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200960076 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 200960076 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 200960076 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 200960076 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 200960076 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 200960076 times.
✗ Branch 13 not taken.
200960076 size_t pos = COMBOPOS(ffc.x+8, ffc.y+8);
22349
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 200958842 times.
200960076 if(cmb->type == cLIGHTTARGET)
22350 {
22351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
22352 1234 hastrigs = true;
22353 1234 bool trigged = (istrig[pos]&trigflag);
22354
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
22355 trigged = !trigged;
22356
2/2
✓ Branch 0 taken 985 times.
✓ Branch 1 taken 249 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
22357 {
22358
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
22359 {
22360 ffc.incData(-1);
22361 istrigged = false;
22362 }
22363 249 }
22364 else //Unsolved version
22365 {
22366
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
22367
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ffc.incData(1);
22368 984 else istrigged = false;
22369 }
22370 1234 }
22371
2/2
✓ Branch 0 taken 200956374 times.
✓ Branch 1 taken 2468 times.
200958842 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
22372 {
22373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2468 times.
2468 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
22374 2468 bool trigged = (istrig[pos]&trigflag);
22375
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2406 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2464 times.
2468 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
22376 2406 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
22377 {
22378
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 do_trigger_combo_ffc(i);
22379 4 }
22380 2468 }
22381 200960076 }
22382
6/6
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 6404908 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 984 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 249 times.
6406142 if(hastrigs && istrigged && !alltrig)
22383 {
22384
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 hidden_entrance(0,true,false,-7);
22385
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 sfx(tmpscr->secretsfx);
22386
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(tmpscr->flags5&fTEMPSECRETS))
22387 {
22388
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag(mSECRET);
22389
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag(mLIGHTBEAM);
22390 1 }
22391 1 }
22392 6406142 }
22393
22394 6395885 void HeroClass::checktouchblk()
22395 {
22396
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6382479 times.
6395885 if(toogam) return;
22397
22398
2/2
✓ Branch 0 taken 441054 times.
✓ Branch 1 taken 5941425 times.
6382479 if(!pushing)
22399 5941425 return;
22400
22401 441054 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
22402
22403
4/4
✓ Branch 0 taken 440874 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 440778 times.
441054 if(charging > 0 || spins > 0) //if not I probably will at some point...
22404 {
22405
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 if(Up()&&Left())tdir = (charging%2)*2;
22406
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 else if(Up()&&Right())tdir = (charging%2)*3;
22407
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Left())tdir = 1+(charging%2)*1;
22408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Right())tdir = 1+(charging%2)*2;
22409 else
22410 {
22411
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
276 if(Up())tdir=0;
22412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(Down())tdir=1;
22413
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(Left())tdir=2;
22414 else if(Right())tdir=3;
22415 }
22416 276 }
22417
22418 441054 int32_t tx=0,ty=-1;
22419
22420
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 109730 times.
✓ Branch 2 taken 93396 times.
✓ Branch 3 taken 114363 times.
✓ Branch 4 taken 123565 times.
441054 switch(tdir)
22421 {
22422 case up:
22423
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 109635 times.
109730 if(touchcombo(x,y+(bigHitbox?0:7)))
22424 {
22425 95 tx=x;
22426 95 ty=y+(bigHitbox?0:7);
22427 95 }
22428
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 109614 times.
109635 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
22429 {
22430 21 tx=x+8;
22431 21 ty=y+(bigHitbox?0:7);
22432 21 }
22433
22434 109730 break;
22435
22436 case down:
22437
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 91996 times.
93396 if(touchcombo(x,y+16))
22438 {
22439 1400 tx=x;
22440 1400 ty=y+16;
22441 1400 }
22442
2/2
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 91759 times.
91996 else if(touchcombo(x+8,y+16))
22443 {
22444 237 tx=x+8;
22445 237 ty=y+16;
22446 237 }
22447
22448 93396 break;
22449
22450 case left:
22451
2/2
✓ Branch 0 taken 113667 times.
✓ Branch 1 taken 696 times.
114363 if(touchcombo(x-1,y+15))
22452 {
22453 696 tx=x-1;
22454 696 ty=y+15;
22455 696 }
22456
22457 114363 break;
22458
22459 case right:
22460
2/2
✓ Branch 0 taken 122482 times.
✓ Branch 1 taken 1083 times.
123565 if(touchcombo(x+16,y+15))
22461 {
22462 1083 tx=x+16;
22463 1083 ty=y+15;
22464 1083 }
22465
22466 123565 break;
22467 }
22468
22469
2/2
✓ Branch 0 taken 437522 times.
✓ Branch 1 taken 3532 times.
441054 if(ty>=0)
22470 {
22471 3532 ty&=0xF0;
22472 3532 tx&=0xF0;
22473 3532 int32_t di = ty+(tx>>4);
22474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3532 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3532 if((getAction() != hopping || isSideViewHero()))
22475 {
22476 3532 trigger_armos_grave(0, di, dir);
22477 3532 }
22478 3532 }
22479 6395885 }
22480
22481 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
22482 {
22483 switch(cdir)
22484 {
22485 case up:
22486 cy-=16;
22487 break;
22488
22489 case down:
22490 cy+=16;
22491 break;
22492
22493 case left:
22494 cx-=16;
22495 break;
22496
22497 case right:
22498 cx+=16;
22499 break;
22500 }
22501
22502 // off the screen
22503 if(cx<0 || cy<0 || cx>255 || cy>175)
22504 {
22505 int32_t ns = nextscr(cdir);
22506
22507 if(ns==0xFFFF) return 0;
22508
22509 // want actual screen index, not game->maps[] index
22510 ns = (ns&127) + (ns>>7)*MAPSCRS;
22511
22512 switch(cdir)
22513 {
22514 case up:
22515 cy=160;
22516 break;
22517
22518 case down:
22519 cy=0;
22520 break;
22521
22522 case left:
22523 cx=240;
22524 break;
22525
22526 case right:
22527 cx=0;
22528 break;
22529 }
22530
22531 // from MAPCOMBO()
22532 int32_t cmb = (cy&0xF0)+(cx>>4);
22533
22534 if(cmb>175)
22535 return 0;
22536
22537 return TheMaps[ns].data[cmb]; // entire combo code
22538 }
22539
22540 return MAPCOMBO(cx,cy);
22541 }
22542
22543 8492 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
22544 {
22545
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1729 times.
✓ Branch 2 taken 2005 times.
✓ Branch 3 taken 2441 times.
✓ Branch 4 taken 2317 times.
8492 switch(cdir)
22546 {
22547 case up:
22548 1729 cy-=16;
22549 1729 break;
22550
22551 case down:
22552 2005 cy+=16;
22553 2005 break;
22554
22555 case left:
22556 2441 cx-=16;
22557 2441 break;
22558
22559 case right:
22560 2317 cx+=16;
22561 2317 break;
22562 }
22563
22564 // off the screen
22565
8/8
✓ Branch 0 taken 8445 times.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 8386 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 8273 times.
✓ Branch 5 taken 113 times.
✓ Branch 6 taken 101 times.
✓ Branch 7 taken 8172 times.
8492 if(cx<0 || cy<0 || cx>255 || cy>175)
22566 {
22567 320 int32_t ns = nextscr(cdir);
22568
22569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(ns==0xFFFF) return 0;
22570
22571 // want actual screen index, not game->maps[] index
22572 320 ns = (ns&127) + (ns>>7)*MAPSCRS;
22573
22574
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 113 times.
320 switch(cdir)
22575 {
22576 case up:
22577 59 cy=160;
22578 59 break;
22579
22580 case down:
22581 101 cy=0;
22582 101 break;
22583
22584 case left:
22585 47 cx=240;
22586 47 break;
22587
22588 case right:
22589 113 cx=0;
22590 113 break;
22591 }
22592
22593 // from MAPCOMBO()
22594 320 int32_t cmb = (cy&0xF0)+(cx>>4);
22595
22596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(cmb>175)
22597 return 0;
22598
22599
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 255 times.
320 if(!comboflag)
22600 {
22601 255 return TheMaps[ns].sflag[cmb]; // flag
22602 }
22603 else
22604 {
22605 65 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
22606 }
22607 }
22608
22609
2/2
✓ Branch 0 taken 2006 times.
✓ Branch 1 taken 6166 times.
8172 if(comboflag)
22610 {
22611 2006 return MAPCOMBOFLAG(cx,cy);
22612 }
22613
22614 6166 return MAPFLAG(cx,cy);
22615 8492 }
22616
22617 bool did_secret;
22618
22619 6395885 void HeroClass::checkspecial()
22620 {
22621 6395885 checktouchblk();
22622
22623 6395885 bool hasmainguy = hasMainGuy(); // calculate it once
22624
22625
4/4
✓ Branch 0 taken 6328542 times.
✓ Branch 1 taken 67343 times.
✓ Branch 2 taken 4084278 times.
✓ Branch 3 taken 2244264 times.
6395885 if(!(loaded_enemies && !hasmainguy))
22626 4151621 did_secret=false;
22627 else
22628 {
22629 // after beating enemies
22630
22631 // generic 'Enemies->' trigger
22632
2/2
✓ Branch 0 taken 15709848 times.
✓ Branch 1 taken 2244264 times.
17954112 for(auto lyr = 0; lyr < 7; ++lyr)
22633 {
22634
2/2
✓ Branch 0 taken 2764933248 times.
✓ Branch 1 taken 15709848 times.
2780643096 for(auto pos = 0; pos < 176; ++pos)
22635 {
22636 2764933248 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
22637
2/2
✓ Branch 0 taken 2764933245 times.
✓ Branch 1 taken 3 times.
2764933248 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
22638 {
22639 3 do_trigger_combo(lyr,pos);
22640 3 }
22641 2764933248 }
22642 15709848 }
22643 2244264 word c = tmpscr->numFFC();
22644
2/2
✓ Branch 0 taken 68834130 times.
✓ Branch 1 taken 2244264 times.
71078394 for(word i=0; i<c; i++)
22645 {
22646 68834130 ffcdata& ffc = tmpscr->ffcs[i];
22647 68834130 newcombo const& cmb = combobuf[ffc.getData()];
22648
1/2
✓ Branch 0 taken 68834130 times.
✗ Branch 1 not taken.
68834130 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
22649 {
22650 do_trigger_combo_ffc(i);
22651 }
22652 68834130 }
22653
1/2
✓ Branch 0 taken 2244264 times.
✗ Branch 1 not taken.
2244264 if(tmpscr->flags9 & fENEMY_WAVES)
22654 {
22655 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
22656 }
22657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2244264 times.
2244264 if(!hasmainguy)
22658 {
22659 // item
22660
2/2
✓ Branch 0 taken 2243812 times.
✓ Branch 1 taken 452 times.
2244264 if(hasitem&(4|2|1))
22661 {
22662 452 int32_t Item=tmpscr->item;
22663
22664 //if(getmapflag())
22665 // Item=0;
22666
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 452 times.
452 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
22667 {
22668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
452 if(hasitem==1)
22669 452 sfx(WAV_CLEARED);
22670
22671
2/4
✓ Branch 0 taken 452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
904 items.add(new item((zfix)tmpscr->itemx,
22672
6/12
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 452 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 452 times.
✗ Branch 11 not taken.
452 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
22673
6/10
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 426 times.
✗ Branch 9 not taken.
452 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
22674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
452 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
22675 452 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
22676 452 }
22677
22678 452 hasitem &= ~ (4|2|1);
22679 452 }
22680 // if room has traps, guys don't come back
22681
2/2
✓ Branch 0 taken 1149063168 times.
✓ Branch 1 taken 2244264 times.
1151307432 for(int32_t i=0; i<eMAXGUYS; i++)
22682 {
22683
4/4
✓ Branch 0 taken 33404758 times.
✓ Branch 1 taken 1115658410 times.
✓ Branch 2 taken 28973436 times.
✓ Branch 3 taken 4431322 times.
1149063168 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
22684
4/4
✓ Branch 0 taken 22637 times.
✓ Branch 1 taken 4408685 times.
✓ Branch 2 taken 22611 times.
✓ Branch 3 taken 26 times.
4431348 if(guys.idCount(i) && !getmapflag(mTMPNORET))
22685 26 setmapflag(mTMPNORET);
22686 1149063168 }
22687 // clear enemies and open secret
22688
4/4
✓ Branch 0 taken 2128225 times.
✓ Branch 1 taken 116039 times.
✓ Branch 2 taken 2127774 times.
✓ Branch 3 taken 451 times.
2244264 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
22689 {
22690 451 bool only16_31 = get_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
22691 451 hidden_entrance(0,true,only16_31,-2);
22692
22693
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 427 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 19 times.
451 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
22694 {
22695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
22696 19 }
22697
22698 451 sfx(tmpscr->secretsfx);
22699 451 did_secret=true;
22700 451 }
22701 2244264 }
22702 }
22703
22704 // doors
22705 6395885 bool has_shutter = false;
22706
2/2
✓ Branch 0 taken 4975094 times.
✓ Branch 1 taken 22985752 times.
27960846 for(int32_t i=0; i<4; i++)
22707
2/2
✓ Branch 0 taken 21564961 times.
✓ Branch 1 taken 1420791 times.
22985752 if(tmpscr->door[i]==dSHUTTER)
22708 {
22709 1420791 has_shutter = true;
22710
4/4
✓ Branch 0 taken 1393331 times.
✓ Branch 1 taken 27460 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 1392416 times.
1420791 if(opendoors==0 && loaded_enemies)
22711 {
22712
4/4
✓ Branch 0 taken 1155712 times.
✓ Branch 1 taken 236704 times.
✓ Branch 2 taken 1154083 times.
✓ Branch 3 taken 1629 times.
1392416 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
22713 1629 opendoors=12;
22714 1392416 }
22715
2/2
✓ Branch 0 taken 22475 times.
✓ Branch 1 taken 5900 times.
28375 else if(opendoors<0)
22716 5900 ++opendoors;
22717
2/2
✓ Branch 0 taken 20594 times.
✓ Branch 1 taken 1881 times.
22475 else if((--opendoors)==0)
22718 1881 openshutters();
22719
22720 1420791 break;
22721 }
22722
10/10
✓ Branch 0 taken 4975094 times.
✓ Branch 1 taken 1420791 times.
✓ Branch 2 taken 4867931 times.
✓ Branch 3 taken 107163 times.
✓ Branch 4 taken 4805265 times.
✓ Branch 5 taken 62666 times.
✓ Branch 6 taken 4748483 times.
✓ Branch 7 taken 56782 times.
✓ Branch 8 taken 2697816 times.
✓ Branch 9 taken 2050667 times.
6395885 if(!has_shutter && !opendoors && loaded_enemies && !(tmpscr->flags&fSHUTTERS) && !hasmainguy)
22723 {
22724 2050667 openshutters();
22725 2050667 }
22726
22727 // set boss flag when boss is gone
22728
6/6
✓ Branch 0 taken 6328542 times.
✓ Branch 1 taken 67343 times.
✓ Branch 2 taken 113421 times.
✓ Branch 3 taken 6215121 times.
✓ Branch 4 taken 85999 times.
✓ Branch 5 taken 27422 times.
6395885 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
22729 {
22730 27422 game->lvlitems[dlevel]|=liBOSS;
22731 27422 stop_sfx(tmpscr->bosssfx);
22732 27422 }
22733
22734
2/2
✓ Branch 0 taken 6381586 times.
✓ Branch 1 taken 14299 times.
6395885 if(getmapflag(mCHEST)) // if special stuff done before
22735 {
22736 14299 remove_chests((currscr>=128)?1:0);
22737 14299 }
22738
22739
1/2
✓ Branch 0 taken 6395885 times.
✗ Branch 1 not taken.
6395885 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
22740 {
22741 remove_lockedchests((currscr>=128)?1:0);
22742 }
22743
22744
1/2
✓ Branch 0 taken 6395885 times.
✗ Branch 1 not taken.
6395885 if(getmapflag(mBOSSCHEST)) // if special stuff done before
22745 {
22746 remove_bosschests((currscr>=128)?1:0);
22747 }
22748
22749 6395885 clear_xstatecombos((currscr>=128)?1:0);
22750
22751
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6395885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6395885 if((hasitem&8) && triggered_screen_secrets)
22752 {
22753 int32_t Item=tmpscr->item;
22754
22755 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
22756 {
22757 items.add(new item((zfix)tmpscr->itemx,
22758 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
22759 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
22760 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
22761 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
22762 }
22763
22764 hasitem &= ~8;
22765 }
22766 6395885 }
22767
22768 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
22769 4376014 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
22770 {
22771 int32_t tmp;
22772 4376014 poses[0] = COMBOPOS(x1,y1);
22773
22774 4376014 tmp = COMBOPOS(x1,y2);
22775
2/2
✓ Branch 0 taken 3464011 times.
✓ Branch 1 taken 912003 times.
4376014 if(tmp == poses[0])
22776 3464011 poses[1] = -1;
22777 912003 else poses[1] = tmp;
22778
22779 4376014 tmp = COMBOPOS(x2,y1);
22780
3/4
✓ Branch 0 taken 1907550 times.
✓ Branch 1 taken 2468464 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1907550 times.
4376014 if(tmp == poses[0] || tmp == poses[1])
22781 2468464 poses[2] = -1;
22782 1907550 else poses[2] = tmp;
22783
22784 4376014 tmp = COMBOPOS(x2,y2);
22785
6/6
✓ Branch 0 taken 2448399 times.
✓ Branch 1 taken 1927615 times.
✓ Branch 2 taken 1907550 times.
✓ Branch 3 taken 540849 times.
✓ Branch 4 taken 1536396 times.
✓ Branch 5 taken 371154 times.
4376014 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
22786 4004860 poses[3] = -1;
22787 371154 else poses[3] = tmp;
22788 4376014 }
22789
22790 6391319 void HeroClass::checkspecial2(int32_t *ls)
22791 {
22792
6/8
✓ Branch 0 taken 5742512 times.
✓ Branch 1 taken 648807 times.
✓ Branch 2 taken 5691235 times.
✓ Branch 3 taken 51277 times.
✓ Branch 4 taken 5691235 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5691235 times.
6391319 if(get_bit(quest_rules,qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
22793 {
22794 // Must run fairycircle stuff if currently active, otherwise hero gets stuck!
22795
2/2
✓ Branch 0 taken 15761 times.
✓ Branch 1 taken 5675474 times.
5691235 if (!fairyclk)
22796 {
22797
2/2
✓ Branch 0 taken 1645947 times.
✓ Branch 1 taken 4029527 times.
5675474 if(y.getInt()&7)
22798 1645947 return;
22799
22800
2/2
✓ Branch 0 taken 2204063 times.
✓ Branch 1 taken 1825464 times.
4029527 if(x.getInt()&7)
22801 2204063 return;
22802 1825464 }
22803 1841225 }
22804
22805
2/2
✓ Branch 0 taken 4512 times.
✓ Branch 1 taken 2536797 times.
2541309 if(toogam) return;
22806
22807 2536797 bool didstrig = false;
22808
22809
2/2
✓ Branch 0 taken 5073259 times.
✓ Branch 1 taken 2536794 times.
7610053 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
22810 {
22811
4/4
✓ Branch 0 taken 10146518 times.
✓ Branch 1 taken 5073256 times.
✓ Branch 2 taken 20293033 times.
✓ Branch 3 taken 10146515 times.
35512804 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
22812 {
22813
2/2
✓ Branch 0 taken 10146515 times.
✓ Branch 1 taken 10146518 times.
20293033 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
22814 20293033 int32_t stype = cmb.type;
22815 20293033 int32_t warpsound = cmb.attribytes[0];
22816
2/2
✓ Branch 0 taken 20292831 times.
✓ Branch 1 taken 202 times.
20293033 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
22817 202 stype = cNONE;
22818
2/2
✓ Branch 0 taken 20293030 times.
✓ Branch 1 taken 3 times.
20293033 if(stype==cSWARPA)
22819 {
22820
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(tmpscr->flags5&fDIRECTSWARP)
22821 {
22822 didpit=true;
22823 pitx=x;
22824 pity=y;
22825 }
22826
22827 3 sdir=dir;
22828 3 dowarp(0,0,warpsound);
22829 3 return;
22830 }
22831
22832
1/2
✓ Branch 0 taken 20293030 times.
✗ Branch 1 not taken.
20293030 if(stype==cSWARPB)
22833 {
22834 if(tmpscr->flags5&fDIRECTSWARP)
22835 {
22836 didpit=true;
22837 pitx=x;
22838 pity=y;
22839 }
22840
22841 sdir=dir;
22842 dowarp(0,1,warpsound);
22843 return;
22844 }
22845
22846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20293030 times.
20293030 if(stype==cSWARPC)
22847 {
22848 if(tmpscr->flags5&fDIRECTSWARP)
22849 {
22850 didpit=true;
22851 pitx=x;
22852 pity=y;
22853 }
22854
22855 sdir=dir;
22856 dowarp(0,2,warpsound);
22857 return;
22858 }
22859
22860
1/2
✓ Branch 0 taken 20293030 times.
✗ Branch 1 not taken.
20293030 if(stype==cSWARPD)
22861 {
22862 if(tmpscr->flags5&fDIRECTSWARP)
22863 {
22864 didpit=true;
22865 pitx=x;
22866 pity=y;
22867 }
22868
22869 sdir=dir;
22870 dowarp(0,3,warpsound);
22871 return;
22872 }
22873
22874
1/2
✓ Branch 0 taken 20293030 times.
✗ Branch 1 not taken.
20293030 if(stype==cSWARPR)
22875 {
22876 if(tmpscr->flags5&fDIRECTSWARP)
22877 {
22878 didpit=true;
22879 pitx=x;
22880 pity=y;
22881 }
22882
22883 sdir=dir;
22884 dowarp(0,(zc_oldrand()%4),warpsound);
22885 return;
22886 }
22887
22888 20293030 int32_t pos = COMBOPOS(x+j, y+i);
22889
4/4
✓ Branch 0 taken 20290874 times.
✓ Branch 1 taken 2156 times.
✓ Branch 2 taken 20292320 times.
✓ Branch 3 taken 710 times.
20293030 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=pos)
22890 {
22891 // zprint("Step Secs\n");
22892
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710 if(stype==cSTRIGFLAG && canPermSecret())
22893 {
22894 if(!didstrig)
22895 {
22896 stepsecret = pos;
22897
22898 if(!(tmpscr->flags5&fTEMPSECRETS))
22899 {
22900 setmapflag(mSECRET);
22901 }
22902 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
22903 //zprint("Step Secrets SFX: %d\n", thesfx);
22904 sfx(warpsound,pan((int32_t)x));
22905 hidden_entrance(0,true,false);
22906 didstrig = true;
22907 }
22908 }
22909 else
22910 {
22911
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 345 times.
710 if(!didstrig)
22912 {
22913 345 stepsecret = pos;
22914 345 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
22915 345 hidden_entrance(0,true,only16_31);
22916 345 didstrig = true;
22917 //play trigger sound
22918 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
22919 //zprint("Step Secrets SFX: %d\n", thesfx);
22920 //sfx(thesfx,pan((int32_t)x));
22921 345 sfx(warpsound,pan((int32_t)x));
22922 345 }
22923 }
22924 710 }
22925 30439545 }
22926 5073256 }
22927
22928 2536794 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
22929
22930 // check if he's standing on a warp he just came out of
22931 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
22932
2/2
✓ Branch 0 taken 920014 times.
✓ Branch 1 taken 1616780 times.
2536794 if (!get_bit(quest_rules,qr_210_WARPRETURN))
22933 {
22934
6/6
✓ Branch 0 taken 1615450 times.
✓ Branch 1 taken 1330 times.
✓ Branch 2 taken 191215 times.
✓ Branch 3 taken 1424235 times.
✓ Branch 4 taken 14738 times.
✓ Branch 5 taken 176477 times.
1616780 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
22935 {
22936
5/6
✓ Branch 0 taken 175855 times.
✓ Branch 1 taken 622 times.
✓ Branch 2 taken 174867 times.
✓ Branch 3 taken 988 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 174867 times.
176477 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
22937 {
22938
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 174862 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
174867 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
22939 174867 else return;
22940 }
22941 1610 }
22942 1441913 }
22943 else
22944 {
22945
2/2
✓ Branch 0 taken 761390 times.
✓ Branch 1 taken 158624 times.
920014 if((int(y)&0xF8)==warpy)
22946 {
22947
2/2
✓ Branch 0 taken 1380 times.
✓ Branch 1 taken 157244 times.
158624 if(x==warpx)
22948 {
22949
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 157244 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
157244 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
22950 157244 else return;
22951 }
22952 1380 }
22953 }
22954
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 2204517 times.
2204683 if (!RaftPass) warpy=-1;
22955
22956
6/6
✓ Branch 0 taken 2201142 times.
✓ Branch 1 taken 3209 times.
✓ Branch 2 taken 147761 times.
✓ Branch 3 taken 2053381 times.
✓ Branch 4 taken 110603 times.
✓ Branch 5 taken 37158 times.
2204683 if(((int32_t)y<raftwarpy-(get_bit(quest_rules, qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_bit(quest_rules, qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
22957 {
22958 2093748 raftwarpy = -1;
22959 2093748 }
22960
6/6
✓ Branch 0 taken 2201875 times.
✓ Branch 1 taken 2476 times.
✓ Branch 2 taken 130055 times.
✓ Branch 3 taken 2071820 times.
✓ Branch 4 taken 94829 times.
✓ Branch 5 taken 35226 times.
2204351 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
22961 {
22962 2109522 raftwarpx = -1;
22963 2109522 }
22964 2204351 int32_t tx=x;
22965 2204351 int32_t ty=y;
22966
22967 2204351 int32_t flag=0;
22968 2204351 int32_t flag2=0;
22969 2204351 int32_t flag3=0;
22970 2204351 int32_t type=0;
22971 2204351 int32_t water=0;
22972 2204351 int32_t index = 0;
22973
22974 2204351 bool setsave=false;
22975 2204351 int32_t warpsfx2 = 0;
22976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2204351 times.
2204351 if (RaftPass) goto RaftingStuff;
22977
22978 //bool gotpit=false;
22979
22980 int32_t x1,x2,y1,y2;
22981 2204351 x1 = tx;
22982 2204351 x2 = tx+15;
22983 2204351 y1 = ty;
22984 2204351 y2 = ty+15;
22985
22986
5/6
✓ Branch 0 taken 1553997 times.
✓ Branch 1 taken 650354 times.
✓ Branch 2 taken 1553997 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 166 times.
✓ Branch 5 taken 1554163 times.
2204351 if((diagonalMovement||NO_GRIDLOCK))
22987 {
22988 650520 x1 = tx+4;
22989 650520 x2 = tx+11;
22990 650520 y1 = ty+4;
22991 650520 y2 = ty+11;
22992 650520 }
22993
22994 int32_t types[4];
22995 2204683 types[0]=types[1]=types[2]=types[3]=-1;
22996 int32_t cids[4];
22997 int32_t ffcids[4];
22998 2204683 cids[0]=cids[1]=cids[2]=cids[3]=-1;
22999 2204683 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
23000 //
23001 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
23002 //
23003 2204683 types[0] = MAPFLAG(x1,y1);
23004 2204683 types[1] = MAPFLAG(x1,y2);
23005 2204683 types[2] = MAPFLAG(x2,y1);
23006 2204683 types[3] = MAPFLAG(x2,y2);
23007
23008
23009 //MAPFFCOMBO
23010
23011
23012
6/6
✓ Branch 0 taken 2156827 times.
✓ Branch 1 taken 47856 times.
✓ Branch 2 taken 2151187 times.
✓ Branch 3 taken 5640 times.
✓ Branch 4 taken 24740 times.
✓ Branch 5 taken 2126447 times.
2204683 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23013 2126447 flag = types[0];
23014
23015 // 2.10 compatibility...
23016
8/10
✓ Branch 0 taken 48367 times.
✓ Branch 1 taken 29869 times.
✓ Branch 2 taken 40838 times.
✓ Branch 3 taken 7529 times.
✓ Branch 4 taken 29820 times.
✓ Branch 5 taken 11018 times.
✓ Branch 6 taken 29820 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 29820 times.
78236 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
23017 11018 flag = types[0];
23018
23019
23020 2204683 types[0] = MAPCOMBOFLAG(x1,y1);
23021 2204683 types[1] = MAPCOMBOFLAG(x1,y2);
23022 2204683 types[2] = MAPCOMBOFLAG(x2,y1);
23023 2204683 types[3] = MAPCOMBOFLAG(x2,y2);
23024
23025
6/6
✓ Branch 0 taken 2202726 times.
✓ Branch 1 taken 1957 times.
✓ Branch 2 taken 2202348 times.
✓ Branch 3 taken 378 times.
✓ Branch 4 taken 568 times.
✓ Branch 5 taken 2201780 times.
2204683 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23026 2201780 flag2 = types[0];
23027
23028 2204683 types[0] = MAPFFCOMBOFLAG(x1,y1);
23029 2204683 types[1] = MAPFFCOMBOFLAG(x1,y2);
23030 2204683 types[2] = MAPFFCOMBOFLAG(x2,y1);
23031 2204683 types[3] = MAPFFCOMBOFLAG(x2,y2);
23032
23033
23034 //
23035
23036
6/6
✓ Branch 0 taken 2204509 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 2204502 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2204498 times.
2204683 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23037 2204498 flag3 = types[0];
23038
23039 //
23040 // Now, let's check for warp combos...
23041 //
23042
23043 //
23044
23045 2204683 cids[0] = MAPCOMBO(x1,y1);
23046 2204683 cids[1] = MAPCOMBO(x1,y2);
23047 2204683 cids[2] = MAPCOMBO(x2,y1);
23048 2204683 cids[3] = MAPCOMBO(x2,y2);
23049
23050 2204683 types[0] = COMBOTYPE(x1,y1);
23051
23052
2/2
✓ Branch 0 taken 2182185 times.
✓ Branch 1 taken 22498 times.
2204683 if(MAPFFCOMBO(x1,y1))
23053 {
23054 22498 types[0] = FFCOMBOTYPE(x1,y1);
23055 22498 cids[0] = MAPFFCOMBO(x1,y1);
23056 22498 }
23057
23058 2204683 types[1] = COMBOTYPE(x1,y2);
23059
23060
2/2
✓ Branch 0 taken 2187393 times.
✓ Branch 1 taken 17290 times.
2204683 if(MAPFFCOMBO(x1,y2))
23061 {
23062 17290 types[1] = FFCOMBOTYPE(x1,y2);
23063 17290 cids[1] = MAPFFCOMBO(x1,y2);
23064 17290 }
23065
23066 2204683 types[2] = COMBOTYPE(x2,y1);
23067
23068
2/2
✓ Branch 0 taken 2181958 times.
✓ Branch 1 taken 22725 times.
2204683 if(MAPFFCOMBO(x2,y1))
23069 {
23070 22725 types[2] = FFCOMBOTYPE(x2,y1);
23071 22725 cids[2] = MAPFFCOMBO(x2,y1);
23072 22725 }
23073 2204683 types[3] = COMBOTYPE(x2,y2);
23074
23075
2/2
✓ Branch 0 taken 2187033 times.
✓ Branch 1 taken 17650 times.
2204683 if(MAPFFCOMBO(x2,y2))
23076 {
23077 17650 types[3] = FFCOMBOTYPE(x2,y2);
23078 17650 cids[3] = MAPFFCOMBO(x2,y2);
23079 17650 }
23080 // Change B, C and D warps into A, for the comparison below...
23081
2/2
✓ Branch 0 taken 8818068 times.
✓ Branch 1 taken 2204683 times.
11022751 for(int32_t i=0; i<4; i++)
23082 {
23083
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 8817744 times.
8818068 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23084 {
23085 324 types[i] = cNONE;
23086 324 continue;
23087 }
23088
2/2
✓ Branch 0 taken 2440 times.
✓ Branch 1 taken 8815304 times.
8817744 if(types[i]==cCAVE)
23089 {
23090 2440 index=0;
23091 2440 warpsfx2 = combobuf[cids[i]].attribytes[0];
23092 2440 }
23093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8815304 times.
8815304 else if(types[i]==cCAVEB)
23094 {
23095 types[i]=cCAVE;
23096 index=1;
23097 warpsfx2 = combobuf[cids[i]].attribytes[0];
23098 }
23099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8815304 times.
8815304 else if(types[i]==cCAVEC)
23100 {
23101 types[i]=cCAVE;
23102 index=2;
23103 warpsfx2 = combobuf[cids[i]].attribytes[0];
23104 }
23105
1/2
✓ Branch 0 taken 8815304 times.
✗ Branch 1 not taken.
8815304 else if(types[i]==cCAVED)
23106 {
23107 types[i]=cCAVE;
23108 index=3;
23109 warpsfx2 = combobuf[cids[i]].attribytes[0];
23110 }
23111
23112
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 8817236 times.
8817744 if(types[i]==cPIT)
23113 {
23114 508 index=0;
23115 508 warpsfx2 = combobuf[cids[i]].attribytes[0];
23116 508 }
23117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8817236 times.
8817236 else if(types[i]==cPITB)
23118 {
23119 types[i]=cPIT;
23120 warpsfx2 = combobuf[cids[i]].attribytes[0];
23121 index=1;
23122 }
23123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8817236 times.
8817236 else if(types[i]==cPITC)
23124 {
23125 types[i]=cPIT;
23126 warpsfx2 = combobuf[cids[i]].attribytes[0];
23127 index=2;
23128 }
23129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8817236 times.
8817236 else if(types[i]==cPITD)
23130 {
23131 types[i]=cPIT;
23132 warpsfx2 = combobuf[cids[i]].attribytes[0];
23133 index=3;
23134 }
23135
1/2
✓ Branch 0 taken 8817236 times.
✗ Branch 1 not taken.
8817236 else if(types[i]==cPITR)
23136 {
23137 types[i]=cPIT;
23138 warpsfx2 = combobuf[cids[i]].attribytes[0];
23139 index=zc_oldrand()%4;
23140 }
23141
23142
2/2
✓ Branch 0 taken 10748 times.
✓ Branch 1 taken 8806996 times.
8817744 if(types[i]==cSTAIR)
23143 {
23144 10748 index=0;
23145 10748 warpsfx2 = combobuf[cids[i]].attribytes[0];
23146 10748 }
23147
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8806896 times.
8806996 else if(types[i]==cSTAIRB)
23148 {
23149 100 types[i]=cSTAIR;
23150 100 warpsfx2 = combobuf[cids[i]].attribytes[0];
23151 100 index=1;
23152 100 }
23153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8806896 times.
8806896 else if(types[i]==cSTAIRC)
23154 {
23155 types[i]=cSTAIR;
23156 warpsfx2 = combobuf[cids[i]].attribytes[0];
23157 index=2;
23158 }
23159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8806896 times.
8806896 else if(types[i]==cSTAIRD)
23160 {
23161 types[i]=cSTAIR;
23162 warpsfx2 = combobuf[cids[i]].attribytes[0];
23163 index=3;
23164 }
23165
1/2
✓ Branch 0 taken 8806896 times.
✗ Branch 1 not taken.
8806896 else if(types[i]==cSTAIRR)
23166 {
23167 types[i]=cSTAIR;
23168 index=zc_oldrand()%4;
23169 warpsfx2 = combobuf[cids[i]].attribytes[0];
23170 }
23171
23172
2/2
✓ Branch 0 taken 1279 times.
✓ Branch 1 taken 8816465 times.
8817744 if(types[i]==cCAVE2)
23173 {
23174 1279 index=0;
23175 1279 warpsfx2 = combobuf[cids[i]].attribytes[0];
23176 1279 }
23177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8816465 times.
8816465 else if(types[i]==cCAVE2B)
23178 {
23179 types[i]=cCAVE2;
23180 index=1;
23181 warpsfx2 = combobuf[cids[i]].attribytes[0];
23182 }
23183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8816465 times.
8816465 else if(types[i]==cCAVE2C)
23184 {
23185 types[i]=cCAVE2;
23186 warpsfx2 = combobuf[cids[i]].attribytes[0];
23187 index=2;
23188 }
23189
1/2
✓ Branch 0 taken 8816465 times.
✗ Branch 1 not taken.
8816465 else if(types[i]==cCAVE2D)
23190 {
23191 types[i]=cCAVE2;
23192 warpsfx2 = combobuf[cids[i]].attribytes[0];
23193 index=3;
23194 }
23195
23196
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 8817668 times.
8817744 if(types[i]==cSWIMWARP)
23197 {
23198 76 index=0;
23199 76 warpsfx2 = combobuf[cids[i]].attribytes[0];
23200 76 }
23201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8817668 times.
8817668 else if(types[i]==cSWIMWARPB)
23202 {
23203 types[i]=cSWIMWARP;
23204 warpsfx2 = combobuf[cids[i]].attribytes[0];
23205 index=1;
23206 }
23207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8817668 times.
8817668 else if(types[i]==cSWIMWARPC)
23208 {
23209 types[i]=cSWIMWARP;
23210 warpsfx2 = combobuf[cids[i]].attribytes[0];
23211 index=2;
23212 }
23213
1/2
✓ Branch 0 taken 8817668 times.
✗ Branch 1 not taken.
8817668 else if(types[i]==cSWIMWARPD)
23214 {
23215 types[i]=cSWIMWARP;
23216 warpsfx2 = combobuf[cids[i]].attribytes[0];
23217 index=3;
23218 }
23219
23220
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 8817236 times.
8817744 if(types[i]==cDIVEWARP)
23221 {
23222 508 index=0;
23223 508 warpsfx2 = combobuf[cids[i]].attribytes[0];
23224 508 }
23225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8817236 times.
8817236 else if(types[i]==cDIVEWARPB)
23226 {
23227 types[i]=cDIVEWARP;
23228 warpsfx2 = combobuf[cids[i]].attribytes[0];
23229 index=1;
23230 }
23231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8817236 times.
8817236 else if(types[i]==cDIVEWARPC)
23232 {
23233 types[i]=cDIVEWARP;
23234 warpsfx2 = combobuf[cids[i]].attribytes[0];
23235 index=2;
23236 }
23237
1/2
✓ Branch 0 taken 8817236 times.
✗ Branch 1 not taken.
8817236 else if(types[i]==cDIVEWARPD)
23238 {
23239 types[i]=cDIVEWARP;
23240 warpsfx2 = combobuf[cids[i]].attribytes[0];
23241 index=3;
23242 }
23243
23244
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 8817054 times.
8817744 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
23245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8817054 times.
8817054 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
23246
2/2
✓ Branch 0 taken 8817038 times.
✓ Branch 1 taken 16 times.
8817054 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
23247 8817744 }
23248
23249 // Special case for step combos; otherwise, they act oddly in some cases
23250
8/8
✓ Branch 0 taken 2055113 times.
✓ Branch 1 taken 149570 times.
✓ Branch 2 taken 2037281 times.
✓ Branch 3 taken 17832 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 167319 times.
✓ Branch 6 taken 21683 times.
✓ Branch 7 taken 21600 times.
2204683 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
23251 {
23252
7/8
✓ Branch 0 taken 2000883 times.
✓ Branch 1 taken 14715 times.
✓ Branch 2 taken 2000883 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 628 times.
✓ Branch 5 taken 2000255 times.
✓ Branch 6 taken 130 times.
✓ Branch 7 taken 498 times.
2058964 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
23253 2000753 type = types[1];
23254 2015598 }
23255
23256 //Generic Step
23257
7/8
✓ Branch 0 taken 2188139 times.
✓ Branch 1 taken 16378 times.
✓ Branch 2 taken 2188139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 630 times.
✓ Branch 5 taken 2187509 times.
✓ Branch 6 taken 132 times.
✓ Branch 7 taken 498 times.
2204517 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
23258 {
23259 int32_t poses[4];
23260 int32_t sensPoses[4];
23261 2188007 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
23262 2188007 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
23263
4/6
✓ Branch 0 taken 1538219 times.
✓ Branch 1 taken 649788 times.
✓ Branch 2 taken 1538219 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1538219 times.
2188007 if(diagonalMovement||NO_GRIDLOCK)
23264 649788 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
23265 1538219 else getPoses(poses, tx, ty, tx+15, ty+15);
23266 2188007 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
23267 2188007 bool hasStep[4] = {false};
23268
2/2
✓ Branch 0 taken 8752028 times.
✓ Branch 1 taken 2188007 times.
10940035 for(auto p = 0; p < 4; ++p)
23269 {
23270
2/2
✓ Branch 0 taken 8751163 times.
✓ Branch 1 taken 61259006 times.
70010169 for(auto lyr = 0; lyr < 7; ++lyr)
23271 {
23272
2/2
✓ Branch 0 taken 28508718 times.
✓ Branch 1 taken 32750288 times.
61259006 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
23273
4/4
✓ Branch 0 taken 28508718 times.
✓ Branch 1 taken 32750288 times.
✓ Branch 2 taken 865 times.
✓ Branch 3 taken 61258141 times.
61259006 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
23274 61259006 || types[p] == cSTEP)
23275 {
23276 865 hasStep[p] = true;
23277 865 break;
23278 }
23279 61258141 }
23280 8752028 }
23281 2188007 bool canNormalStep = true;
23282
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 2188413 times.
2188512 for(auto p = 0; p < 4; ++p)
23283 {
23284
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 2188160 times.
2188413 if(poses[p] < 0) continue;
23285
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 2187908 times.
2188160 if(!hasStep[p])
23286 {
23287 2187908 canNormalStep = false;
23288 2187908 break;
23289 }
23290 252 }
23291
2/2
✓ Branch 0 taken 8752028 times.
✓ Branch 1 taken 2188007 times.
10940035 for(auto p = 0; p < 4; ++p)
23292 {
23293
2/2
✓ Branch 0 taken 61264196 times.
✓ Branch 1 taken 8752028 times.
70016224 for(auto lyr = 0; lyr < 7; ++lyr)
23294 {
23295
2/2
✓ Branch 0 taken 28511994 times.
✓ Branch 1 taken 32752202 times.
61264196 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
23296
2/2
✓ Branch 0 taken 24455053 times.
✓ Branch 1 taken 36809143 times.
61264196 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
23297
6/6
✓ Branch 0 taken 2772 times.
✓ Branch 1 taken 61261424 times.
✓ Branch 2 taken 1162 times.
✓ Branch 3 taken 1610 times.
✓ Branch 4 taken 1148 times.
✓ Branch 5 taken 14 times.
61264196 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
23298 {
23299 14 do_trigger_combo(lyr,poses[p]);
23300
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 9 times.
14 if(poses[p] == sensPoses[p]) continue;
23301 9 }
23302
4/4
✓ Branch 0 taken 24455048 times.
✓ Branch 1 taken 36809143 times.
✓ Branch 2 taken 24454983 times.
✓ Branch 3 taken 65 times.
61264191 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
23303 {
23304 65 do_trigger_combo(lyr,sensPoses[p]);
23305 65 }
23306 61264191 }
23307 8752028 }
23308 2188007 word c = tmpscr->numFFC();
23309
2/2
✓ Branch 0 taken 66112437 times.
✓ Branch 1 taken 2188007 times.
68300444 for(word i=0; i<c; i++)
23310 {
23311 66112437 bool found = false;
23312
2/2
✓ Branch 0 taken 132224874 times.
✓ Branch 1 taken 66112437 times.
198337311 for(auto xch = 0; xch < 2; ++xch)
23313 {
23314
2/2
✓ Branch 0 taken 264449748 times.
✓ Branch 1 taken 132224874 times.
396674622 for(auto ych = 0; ych < 2; ++ych)
23315 {
23316
2/2
✓ Branch 0 taken 264367317 times.
✓ Branch 1 taken 82431 times.
264449748 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
23317 {
23318 82431 found = true;
23319 82431 }
23320 264449748 }
23321 132224874 }
23322
2/2
✓ Branch 0 taken 66080434 times.
✓ Branch 1 taken 32003 times.
66112437 if (found)
23323 {
23324 32003 ffcdata& ffc = tmpscr->ffcs[i];
23325 32003 newcombo const* cmb = &combobuf[ffc.getData()];
23326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32003 times.
32003 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
23327 {
23328 do_trigger_combo_ffc(i);
23329 }
23330 32003 }
23331 66112437 }
23332 2188007 }
23333
23334 //
23335 // Now, let's check for Save combos...
23336 //
23337 2204517 x1 = tx+4;
23338 2204517 x2 = tx+11;
23339 2204517 y1 = ty+4;
23340 2204517 y2 = ty+11;
23341
23342 2204517 types[0] = COMBOTYPE(x1,y1);
23343 2204517 cids[0] = MAPCOMBO(x1,y1);
23344
23345
2/2
✓ Branch 0 taken 2182042 times.
✓ Branch 1 taken 22475 times.
2204517 if(MAPFFCOMBO(x1,y1))
23346 {
23347 22475 types[0] = FFCOMBOTYPE(x1,y1);
23348 22475 cids[0] = MAPFFCOMBO(x1,y1);
23349 22475 }
23350
23351 2204517 types[1] = COMBOTYPE(x1,y2);
23352 2204517 cids[1] = MAPCOMBO(x1,y2);
23353
23354
2/2
✓ Branch 0 taken 2187213 times.
✓ Branch 1 taken 17304 times.
2204517 if(MAPFFCOMBO(x1,y2))
23355 {
23356 17304 types[1] = FFCOMBOTYPE(x1,y2);
23357 17304 cids[1] = MAPFFCOMBO(x1,y2);
23358 17304 }
23359
23360 2204517 types[2] = COMBOTYPE(x2,y1);
23361 2204517 cids[2] = MAPCOMBO(x2,y1);
23362
23363
2/2
✓ Branch 0 taken 2181807 times.
✓ Branch 1 taken 22710 times.
2204517 if(MAPFFCOMBO(x2,y1))
23364 {
23365 22710 types[2] = FFCOMBOTYPE(x2,y1);
23366 22710 cids[2] = MAPFFCOMBO(x2,y1);
23367 22710 }
23368
23369 2204517 types[3] = COMBOTYPE(x2,y2);
23370 2204517 cids[3] = MAPCOMBO(x2,y2);
23371
23372
2/2
✓ Branch 0 taken 2186852 times.
✓ Branch 1 taken 17665 times.
2204517 if(MAPFFCOMBO(x2,y2))
23373 {
23374 17665 types[3] = FFCOMBOTYPE(x2,y2);
23375 17665 cids[3] = MAPFFCOMBO(x2,y2);
23376 17665 }
23377
23378
23379
2/2
✓ Branch 0 taken 2204517 times.
✓ Branch 1 taken 8818068 times.
11022585 for(int32_t i=0; i<4; i++)
23380 {
23381
2/2
✓ Branch 0 taken 8817744 times.
✓ Branch 1 taken 324 times.
8818068 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23382 {
23383
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 324 times.
✗ Branch 3 not taken.
324 if(types[i] == cSAVE || types[i] == cSAVE2)
23384 {
23385 types[i] = cNONE;
23386 setsave = false;
23387 break;
23388 }
23389 324 }
23390
2/2
✓ Branch 0 taken 8816782 times.
✓ Branch 1 taken 1286 times.
8818068 if(types[i]==cSAVE) setsave=true;
23391
23392
1/2
✓ Branch 0 taken 8818068 times.
✗ Branch 1 not taken.
8818068 if(types[i]==cSAVE2) setsave=true;
23393 8818068 }
23394
23395
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 2204086 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
2204517 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23396 {
23397 229 last_savepoint_id = cids[0];
23398 229 type = types[0];
23399 229 }
23400 //
23401 // Now, let's check for Drowning combos...
23402 //
23403
3/4
✓ Branch 0 taken 1454895 times.
✓ Branch 1 taken 749622 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1454895 times.
2204517 if(get_bit(quest_rules,qr_DROWN) || CanSideSwim())
23404 {
23405 749622 y1 = ty+9;
23406 749622 y2 = ty+15;
23407
2/2
✓ Branch 0 taken 220107 times.
✓ Branch 1 taken 529515 times.
749622 if (get_bit(quest_rules, qr_SMARTER_WATER))
23408 {
23409
4/4
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 218229 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1596 times.
221706 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
23410
2/2
✓ Branch 0 taken 1722 times.
✓ Branch 1 taken 156 times.
1878 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
23411
2/2
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 123 times.
1722 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
23412 1599 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
23413 220107 }
23414 else
23415 {
23416 529515 types[0] = COMBOTYPE(x1,y1);
23417
23418
2/2
✓ Branch 0 taken 11301 times.
✓ Branch 1 taken 518214 times.
529515 if(MAPFFCOMBO(x1,y1))
23419 11301 types[0] = FFCOMBOTYPE(x1,y1);
23420
23421 529515 types[1] = COMBOTYPE(x1,y2);
23422
23423
2/2
✓ Branch 0 taken 10868 times.
✓ Branch 1 taken 518647 times.
529515 if(MAPFFCOMBO(x1,y2))
23424 10868 types[1] = FFCOMBOTYPE(x1,y2);
23425
23426 529515 types[2] = COMBOTYPE(x2,y1);
23427
23428
2/2
✓ Branch 0 taken 12015 times.
✓ Branch 1 taken 517500 times.
529515 if(MAPFFCOMBO(x2,y1))
23429 12015 types[2] = FFCOMBOTYPE(x2,y1);
23430
23431 529515 types[3] = COMBOTYPE(x2,y2);
23432
23433
2/2
✓ Branch 0 taken 11358 times.
✓ Branch 1 taken 518157 times.
529515 if(MAPFFCOMBO(x2,y2))
23434 11358 types[3] = FFCOMBOTYPE(x2,y2);
23435
23436 529515 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
23437
2/2
✓ Branch 0 taken 11562 times.
✓ Branch 1 taken 517953 times.
529515 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
23438 11562 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
23439
23440
5/6
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 527623 times.
✓ Branch 2 taken 1888 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1852 times.
✗ Branch 5 not taken.
531367 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
23441
3/4
✓ Branch 0 taken 1852 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 1852 times.
✗ Branch 3 not taken.
1888 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
23442 1852 water = typec;
23443 }
23444 749622 }
23445
23446
23447 // Pits have a bigger 'hitbox' than stairs...
23448 2204517 x1 = tx+7;
23449 2204517 x2 = tx+8;
23450 2204517 y1 = ty+7+(bigHitbox?0:4);
23451 2204517 y2 = ty+8+(bigHitbox?0:4);
23452
23453 2204517 types[0] = COMBOTYPE(x1,y1);
23454 2204517 cids[0] = MAPCOMBO(x1,y1);
23455
23456
2/2
✓ Branch 0 taken 2186744 times.
✓ Branch 1 taken 17773 times.
2204517 if(MAPFFCOMBO(x1,y1))
23457 {
23458 17773 types[0] = FFCOMBOTYPE(x1,y1);
23459 17773 cids[0] = MAPFFCOMBO(x1,y1);
23460 17773 }
23461
23462 2204517 types[1] = COMBOTYPE(x1,y2);
23463 2204517 cids[1] = MAPCOMBO(x1,y2);
23464
23465
2/2
✓ Branch 0 taken 2186650 times.
✓ Branch 1 taken 17867 times.
2204517 if(MAPFFCOMBO(x1,y2))
23466 {
23467 17867 types[1] = FFCOMBOTYPE(x1,y2);
23468 17867 cids[1] = MAPFFCOMBO(x1,y2);
23469 17867 }
23470 2204517 types[2] = COMBOTYPE(x2,y1);
23471 2204517 cids[2] = MAPCOMBO(x2,y1);
23472
23473
2/2
✓ Branch 0 taken 2187056 times.
✓ Branch 1 taken 17461 times.
2204517 if(MAPFFCOMBO(x2,y1))
23474 {
23475 17461 types[2] = FFCOMBOTYPE(x2,y1);
23476 17461 cids[2] = MAPFFCOMBO(x2,y1);
23477 17461 }
23478
23479 2204517 types[3] = COMBOTYPE(x2,y2);
23480 2204517 cids[3] = MAPCOMBO(x2,y2);
23481
23482
2/2
✓ Branch 0 taken 2186955 times.
✓ Branch 1 taken 17562 times.
2204517 if(MAPFFCOMBO(x2,y2))
23483 {
23484 17562 types[3] = FFCOMBOTYPE(x2,y2);
23485 17562 cids[3] = MAPFFCOMBO(x2,y2);
23486 17562 }
23487
23488
2/2
✓ Branch 0 taken 8818068 times.
✓ Branch 1 taken 2204517 times.
11022585 for(int32_t i=0; i<4; i++)
23489 {
23490
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 8817804 times.
8818068 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23491 {
23492 264 types[i] = cNONE;
23493 264 continue;
23494 }
23495
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 8817424 times.
8817804 if(types[i]==cPIT)
23496 {
23497 380 index=0;
23498 380 warpsfx2 = combobuf[cids[i]].attribytes[0];
23499 380 }
23500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8817424 times.
8817424 else if(types[i]==cPITB)
23501 {
23502 types[i]=cPIT;
23503 index=1;
23504 warpsfx2 = combobuf[cids[i]].attribytes[0];
23505 }
23506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8817424 times.
8817424 else if(types[i]==cPITC)
23507 {
23508 types[i]=cPIT;
23509 index=2;
23510 warpsfx2 = combobuf[cids[i]].attribytes[0];
23511 }
23512
1/2
✓ Branch 0 taken 8817424 times.
✗ Branch 1 not taken.
8817424 else if(types[i]==cPITD)
23513 {
23514 types[i]=cPIT;
23515 index=3;
23516 warpsfx2 = combobuf[cids[i]].attribytes[0];
23517 }
23518 8817804 }
23519
23520
6/8
✓ Branch 0 taken 2204424 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 2204424 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2204405 times.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2204405 times.
2204517 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
23521
3/8
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 112 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
224 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
23522 112 type=cPIT;
23523
23524 //
23525 // Time to act on our results for type, flag, flag2 and flag3...
23526 //
23527
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 2204288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
2204517 if(type==cSAVE&&currscr<128)
23528 229 *ls=1;
23529
23530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2204517 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2204517 if(type==cSAVE2&&currscr<128)
23531 *ls=2;
23532
23533
7/8
✓ Branch 0 taken 2196499 times.
✓ Branch 1 taken 8018 times.
✓ Branch 2 taken 2185427 times.
✓ Branch 3 taken 11072 times.
✓ Branch 4 taken 2184897 times.
✓ Branch 5 taken 530 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2184897 times.
2204517 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
23534 {
23535 19620 fairycircle(REFILL_LIFE);
23536
23537
2/2
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 3259 times.
19620 if(fairyclk!=0) return;
23538 3259 }
23539
23540
4/8
✓ Branch 0 taken 2188156 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2188156 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2188156 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2188156 times.
2188156 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
23541 {
23542 fairycircle(REFILL_MAGIC);
23543
23544 if(fairyclk!=0) return;
23545 }
23546
23547
4/8
✓ Branch 0 taken 2188156 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2188156 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2188156 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2188156 times.
2188156 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
23548 {
23549 fairycircle(REFILL_ALL);
23550
23551 if(fairyclk!=0) return;
23552 }
23553
23554 // Just in case Hero was moved off of the fairy flag
23555
1/2
✓ Branch 0 taken 2188156 times.
✗ Branch 1 not taken.
2188156 if(refilling==REFILL_FAIRYDONE)
23556 {
23557 fairycircle(REFILL_NONE);
23558
23559 if(fairyclk!=0) return;
23560 }
23561
23562
5/8
✓ Branch 0 taken 2188147 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 2188147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2188147 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2188147 times.
2188156 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
23563 {
23564 9 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
23565 9 win_game();
23566 9 return;
23567 }
23568
23569
4/4
✓ Branch 0 taken 2184307 times.
✓ Branch 1 taken 3840 times.
✓ Branch 2 taken 2184307 times.
✓ Branch 3 taken 3840 times.
2188147 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
23570 3840 return;
23571
23572
4/4
✓ Branch 0 taken 2183982 times.
✓ Branch 1 taken 325 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2183973 times.
2184307 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
23573 {
23574
23575
3/4
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
334 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_bit(quest_rules,qr_TRIGGERSREPEAT))
23576 {
23577 334 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
23578 334 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
23579 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
23580
23581
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 325 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
334 if(type==cTRIGFLAG && canPermSecret())
23582 {
23583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
23584
23585 9 hidden_entrance(0,true,false);
23586 9 }
23587 else
23588 {
23589 325 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
23590 325 hidden_entrance(0,true,only16_31);
23591 }
23592 334 }
23593 334 }
23594
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 2183631 times.
2183973 else if(!didstrig)
23595 {
23596 2183631 stepsecret = -1;
23597 2183631 }
23598
23599 //Better? Dock collision
23600
23601 // Drown if:
23602 // * Water (obviously walkable),
23603 // * Quest Rule allows it,
23604 // * Not on stepladder,
23605 // * Not jumping,
23606 // * Not hovering,
23607 // * Not rafting,
23608 // * Not swallowed,
23609 // * Not a dried lake.
23610
23611 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
23612
23613
13/22
✓ Branch 0 taken 3392 times.
✓ Branch 1 taken 2180915 times.
✓ Branch 2 taken 3392 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3392 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3392 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3392 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 3385 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3009 times.
✓ Branch 15 taken 376 times.
✓ Branch 16 taken 3009 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 3009 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
2184307 if(water > 0 && ((get_bit(quest_rules,qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim()) && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE)
23614 {
23615
4/8
✓ Branch 0 taken 3000 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 3000 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3000 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3009 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
23616 {
23617
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!(ladderx+laddery)) drownCombo = water;
23618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (combobuf[water].usrflags&cflag1) Drown(1);
23619 9 else Drown();
23620
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 if(byte drown_sfx = combobuf[water].attribytes[4])
23621 8 sfx(drown_sfx, pan(int32_t(x)));
23622 9 }
23623
2/2
✓ Branch 0 taken 2891 times.
✓ Branch 1 taken 109 times.
3000 else if (!isSwimming())
23624 {
23625 109 SetSwim();
23626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (!IsSideSwim()) attackclk = charging = spins = 0;
23627 109 landswim=0;
23628 109 return;
23629 }
23630 2900 }
23631
23632
23633
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 2184035 times.
2184198 if(type==cSTEP)
23634 {
23635 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
23636
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 66 times.
163 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
23637 {
23638 66 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
23639
23640 if
23641 (
23642
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 4 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
23643
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
23644 && /*HEAVY*/
23645
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23646 )
23647
23648 {
23649 62 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
23650 62 tmpscr->data[stepnext]++;
23651
23652 62 }
23653
23654 if
23655 (
23656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
23657 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
23658 && /*HEAVY*/
23659 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23660 )
23661 {
23662 int32_t stepc = tmpscr->data[stepnext];
23663 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
23664 for(int32_t k=0; k<176; k++)
23665 {
23666 if(tmpscr->data[k]==stepc)
23667 {
23668 tmpscr->data[k]++;
23669 }
23670 }
23671 }
23672
23673 if
23674 (
23675
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 63 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
23676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
23677 && /*HEAVY*/
23678
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23679 )
23680 {
23681 3 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
23682
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 for(int32_t k=0; k<176; k++)
23683 {
23684 if(
23685
3/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 507 times.
1050 (combobuf[tmpscr->data[k]].type==cSTEP)||
23686
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
23687
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 6 times.
528 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
23688 522 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
23689 )
23690 {
23691 21 tmpscr->data[k]++;
23692 21 }
23693 528 }
23694 3 }
23695 66 }
23696 163 }
23697
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2184035 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2184035 else if(type==cSTEPSFX && action == walking)
23698 {
23699 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
23700 }
23701 2184035 else stepnext = -1;
23702
23703 2184198 detail_int[0]=tx;
23704 2184198 detail_int[1]=ty;
23705
23706
23707
8/8
✓ Branch 0 taken 2183971 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 341 times.
✓ Branch 3 taken 2183857 times.
✓ Branch 4 taken 2183050 times.
✓ Branch 5 taken 807 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 8 times.
2184211 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
23708
5/6
✓ Branch 0 taken 2182938 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 2182927 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 2182927 times.
✗ Branch 5 not taken.
2183050 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
23709
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2182914 times.
2182927 !(type==cDIVEWARP && isDiving()))
23710 2182922 {
23711 RaftingStuff:
23712
2/2
✓ Branch 0 taken 2182363 times.
✓ Branch 1 taken 559 times.
2182922 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
23713 {
23714 559 bool doraft = true;
23715
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
23716 {
23717
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23718 {
23719 3 doraft = false;
23720 3 }
23721 3 }
23722 //if (mfRAFT)
23723 int32_t rafttypes[2];
23724 559 int32_t raftx1 = tx+6;
23725 559 int32_t raftx2 = tx+9;
23726 559 int32_t rafty = ty+11;
23727 int32_t raftflags[3];
23728 559 rafttypes[0]=rafttypes[1]=-1;
23729 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
23730 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
23731 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
23732
23733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23734 559 raftflags[0] = rafttypes[0];
23735
23736
23737 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
23738 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
23739
23740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23741 559 raftflags[1] = rafttypes[0];
23742
23743 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
23744 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
23745
23746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23747 559 raftflags[2] = rafttypes[0];
23748
23749
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
23750 {
23751
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
23752 {
23753 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
23754 {
23755 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
23756 {
23757 reset_swordcharge();
23758 action=rafting; FFCore.setHeroAction(rafting);
23759 raftclk=0;
23760 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23761 else sfx(tmpscr->secretsfx);
23762 }
23763 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23764 {
23765 for (int32_t i = 0; i < 4; ++i)
23766 {
23767 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
23768 {
23769 reset_swordcharge();
23770 action=rafting; FFCore.setHeroAction(rafting);
23771 raftclk=0;
23772 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23773 else sfx(tmpscr->secretsfx);
23774 dir = i;
23775 break;
23776 }
23777 }
23778 }
23779 }
23780 }
23781 1677 }
23782 559 }
23783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2182922 times.
2182922 if (RaftPass) return;
23784
3/3
✓ Branch 0 taken 10772 times.
✓ Branch 1 taken 2171744 times.
✓ Branch 2 taken 406 times.
2182922 switch(flag)
23785 {
23786 case mfDIVE_ITEM:
23787
6/8
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 397 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
406 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23788 {
23789 12 additem(x, y, tmpscr->catchall,
23790 6 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23791 6 sfx(tmpscr->secretsfx);
23792 6 }
23793
23794 406 return;
23795
23796 case mfRAFT:
23797 case mfRAFT_BRANCH:
23798
23799 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
23800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10772 times.
10772 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
23801 {
23802 10772 bool doraft = true;
23803
5/6
✓ Branch 0 taken 10772 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 948 times.
✓ Branch 3 taken 9824 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 826 times.
10772 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
23804 {
23805
5/6
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392 times.
✓ Branch 3 taken 434 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 374 times.
826 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23806 {
23807 374 doraft = false;
23808 374 }
23809 826 }
23810
13/16
✓ Branch 0 taken 9636 times.
✓ Branch 1 taken 1136 times.
✓ Branch 2 taken 1924 times.
✓ Branch 3 taken 7712 times.
✓ Branch 4 taken 1914 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 1911 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 1911 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1911 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1911 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1262 times.
✓ Branch 15 taken 649 times.
10772 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
23811 {
23812
3/4
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 178 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 471 times.
649 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
23813 {
23814 178 reset_swordcharge();
23815 178 action=rafting; FFCore.setHeroAction(rafting);
23816 178 raftclk=0;
23817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23818 178 else sfx(tmpscr->secretsfx);
23819 178 }
23820
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 471 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
471 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23821 {
23822 for (int32_t i = 0; i < 4; ++i)
23823 {
23824 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
23825 {
23826 reset_swordcharge();
23827 action=rafting; FFCore.setHeroAction(rafting);
23828 raftclk=0;
23829 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23830 else sfx(tmpscr->secretsfx);
23831 dir = i;
23832 break;
23833 }
23834 }
23835 }
23836 649 }
23837 10772 }
23838
23839 10772 return;
23840
23841 default:
23842 2171744 break;
23843 //return;
23844 }
23845
23846
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2171744 times.
✗ Branch 2 not taken.
2171744 switch(flag2)
23847 {
23848 case mfDIVE_ITEM:
23849 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23850 {
23851 additem(x, y, tmpscr->catchall,
23852 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23853 sfx(tmpscr->secretsfx);
23854 }
23855
23856 return;
23857
23858 case mfRAFT:
23859 case mfRAFT_BRANCH:
23860
23861 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
23862 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
23863 {
23864 bool doraft = true;
23865 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
23866 {
23867 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23868 {
23869 doraft = false;
23870 }
23871 }
23872 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
23873 {
23874 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
23875 {
23876 reset_swordcharge();
23877 action=rafting; FFCore.setHeroAction(rafting);
23878 raftclk=0;
23879 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23880 else sfx(tmpscr->secretsfx);
23881 }
23882 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23883 {
23884 for (int32_t i = 0; i < 4; ++i)
23885 {
23886 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
23887 {
23888 reset_swordcharge();
23889 action=rafting; FFCore.setHeroAction(rafting);
23890 raftclk=0;
23891 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23892 else sfx(tmpscr->secretsfx);
23893 dir = i;
23894 break;
23895 }
23896 }
23897 }
23898 }
23899 }
23900
23901 return;
23902
23903 default:
23904 2171744 break;
23905 //return;
23906 }
23907
23908
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2171744 times.
✗ Branch 2 not taken.
2171744 switch(flag3)
23909 {
23910 case mfDIVE_ITEM:
23911 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23912 {
23913 additem(x, y, tmpscr->catchall,
23914 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23915 sfx(tmpscr->secretsfx);
23916 }
23917
23918 return;
23919
23920 case mfRAFT:
23921 case mfRAFT_BRANCH:
23922
23923 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
23924 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
23925 {
23926 bool doraft = true;
23927 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
23928 {
23929 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23930 {
23931 doraft = false;
23932 }
23933 }
23934 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
23935 {
23936 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
23937 {
23938 reset_swordcharge();
23939 action=rafting; FFCore.setHeroAction(rafting);
23940 raftclk=0;
23941 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23942 else sfx(tmpscr->secretsfx);
23943 }
23944 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23945 {
23946 for (int32_t i = 0; i < 4; ++i)
23947 {
23948 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
23949 {
23950 reset_swordcharge();
23951 action=rafting; FFCore.setHeroAction(rafting);
23952 raftclk=0;
23953 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23954 else sfx(tmpscr->secretsfx);
23955 dir = i;
23956 break;
23957 }
23958 }
23959 }
23960 }
23961 }
23962
23963 return;
23964
23965 default:
23966 2171744 return;
23967 }
23968 }
23969
23970
23971 1276 int32_t t=(currscr<128)?0:1;
23972
23973
3/4
✓ Branch 0 taken 1049 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 1276 times.
✗ Branch 3 not taken.
1276 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
23974
23975 //don't do this for canceled warps -DD
23976 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
23977 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
23978 {
23979 draw_screen(tmpscr);
23980 advanceframe(true);
23981 }*/
23982
23983 1276 bool skippedaframe=false;
23984
23985
6/6
✓ Branch 0 taken 1049 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 935 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 807 times.
✓ Branch 5 taken 128 times.
1276 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
23986 {
23987 // Stop music only if:
23988 // * entering a Guy Cave
23989 // * warping to a DMap whose music is different.
23990
23991 1148 int32_t tdm = tmpscr[t].tilewarpdmap[index];
23992
23993
2/2
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 414 times.
1148 if(tmpscr[t].tilewarptype[index]<=wtPASS)
23994 {
23995
3/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 339 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 395 times.
734 if((DMaps[currdmap].flags&dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
23996 395 music_stop();
23997 734 }
23998 else
23999 {
24000
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 404 times.
414 if(zcmusic!=NULL)
24001 {
24002
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 if(strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
24003
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 (zcmusic->type==ZCMF_GME && zcmusic->track!=DMaps[tdm].tmusictrack))
24004 10 music_stop();
24005 10 }
24006
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
404 else if(DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi-ZC_MIDI_COUNT+4) &&
24007 351 TheMaps[(DMaps[tdm].map*MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi-ZC_MIDI_COUNT+4))
24008 351 music_stop();
24009 }
24010
24011 1148 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
24012
5/6
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 414 times.
✓ Branch 2 taken 395 times.
✓ Branch 3 taken 339 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 395 times.
1148 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
24013 809 ? false : COOLSCROLL);
24014
24015 1148 FFCore.warpScriptCheck();
24016 1148 draw_screen(tmpscr);
24017 1148 advanceframe(true);
24018
24019 1148 skippedaframe=true;
24020
24021
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 1034 times.
1148 if(type==cCAVE2) walkup2(opening);
24022
2/2
✓ Branch 0 taken 807 times.
✓ Branch 1 taken 227 times.
1034 else if(type==cCAVE) walkdown(opening);
24023 1148 }
24024
24025
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 112 times.
1276 if(type==cPIT)
24026 {
24027 112 didpit=true;
24028 112 pitx=x;
24029 112 pity=y;
24030 112 warp_sound = warpsfx2;
24031 112 }
24032
24033
5/6
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 582 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 56 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
1332 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
24034
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
694 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
24035 {
24036
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(!skippedaframe)
24037 {
24038 FFCore.warpScriptCheck();
24039 draw_screen(tmpscr);
24040 advanceframe(true);
24041 }
24042
24043 // "take any road you want"
24044
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 11 times.
56 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
24045 56 int32_t code = WARPCODE(currdmap,homescr,dw);
24046
24047
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(code>-1)
24048 {
24049 56 bool changedlevel = false;
24050 56 bool changeddmap = false;
24051
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15 times.
56 if(currdmap != code>>8)
24052 {
24053 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24054 15 changeddmap = true;
24055 15 }
24056
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(dlevel != DMaps[code>>8].level)
24057 {
24058 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24059 changedlevel = true;
24060 }
24061 56 currdmap = code>>8;
24062 56 dlevel = DMaps[currdmap].level;
24063
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15 times.
56 if(changeddmap)
24064 {
24065 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24066 15 }
24067
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(changedlevel)
24068 {
24069 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24070 }
24071
24072 56 currmap = DMaps[currdmap].map;
24073 56 homescr = (code&0xFF) + DMaps[currdmap].xoff;
24074 56 init_dmap();
24075
24076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(canPermSecret())
24077 56 setmapflag(mSECRET);
24078 56 }
24079
24080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(specialcave==STAIRCAVE) exitcave();
24081
24082 56 return;
24083 }
24084
24085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
1220 if(type==cRESET)
24086 {
24087 if(!skippedaframe)
24088 {
24089 FFCore.warpScriptCheck();
24090 draw_screen(tmpscr);
24091 advanceframe(true);
24092 }
24093
24094 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
24095
24096 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
24097
24098 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
24099
24100 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
24101
24102 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
24103
24104 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
24105
24106 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
24107
24108 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
24109
24110 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
24111
24112 if(isdungeon())
24113 {
24114 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
24115
24116 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
24117
24118 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
24119
24120 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
24121 }
24122
24123 didpit=true;
24124 pitx=x;
24125 pity=y;
24126 sdir=dir;
24127 dowarp(4,0, warpsfx2);
24128 }
24129 else
24130 {
24131
3/4
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 1092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
1220 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
24132 {
24133 128 FFCore.warpScriptCheck();
24134 128 draw_screen(tmpscr);
24135 128 advanceframe(true);
24136 128 }
24137
24138 1220 sdir = dir;
24139 1220 dowarp(0,index, warpsfx2);
24140 }
24141 6391153 }
24142
24143 67 int32_t selectWlevel(int32_t d)
24144 {
24145
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(TriforceCount()==0)
24146 return 0;
24147
24148 67 word l = game->get_wlevel();
24149
24150 67 do
24151 {
24152
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
121 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
24153 break;
24154
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 52 times.
121 else if(d<0)
24155
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 11 times.
52 l = (l==0) ? 7 : l-1;
24156 else
24157
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 58 times.
69 l = (l==7) ? 0 : l+1;
24158
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 67 times.
121 }
24159 121 while(!(game->lvlitems[l+1] & liTRIFORCE));
24160
24161 67 game->set_wlevel(l);
24162 67 return l;
24163 67 }
24164
24165 // Would someone tell the Dodongos to shut their yaps?!
24166 11386 void kill_enemy_sfx()
24167 {
24168
2/2
✓ Branch 0 taken 11386 times.
✓ Branch 1 taken 21168 times.
32554 for(int32_t i=0; i<guys.Count(); i++)
24169 {
24170
2/2
✓ Branch 0 taken 7559 times.
✓ Branch 1 taken 13609 times.
21168 if(((enemy*)guys.spr(i))->bgsfx)
24171 13609 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
24172 21168 }
24173
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11320 times.
11386 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
24174
2/2
✓ Branch 0 taken 11373 times.
✓ Branch 1 taken 13 times.
11386 if(tmpscr->room==rGANON)
24175 13 stop_sfx(WAV_ROAR);
24176 11386 }
24177
24178 bool HeroClass::HasHeavyBoots()
24179 {
24180 for ( int32_t q = 0; q < MAXITEMS; ++q )
24181 {
24182 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
24183 }
24184 return false;
24185 }
24186
24187 const char *roomtype_string[rMAX] =
24188 {
24189 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
24190 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
24191 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
24192 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
24193 };
24194
24195 static bool refresh_dmap_scrollscript = false;
24196 2108 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
24197 {
24198 2108 refresh_dmap_scrollscript = false;
24199 2108 byte reposition_sword_postwarp = 0;
24200
1/2
✓ Branch 0 taken 2108 times.
✗ Branch 1 not taken.
2108 if(index<0)
24201 {
24202 return false;
24203 }
24204 2108 is_warping = true;
24205
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 2108 times.
2290 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
24206 {
24207 182 weapon *swd=NULL;
24208 182 swd = (weapon*)Lwpns.spr(q);
24209
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 8 times.
182 if(swd->id == (attack==wSword ? wSword : wWand))
24210 {
24211 8 Lwpns.del(q);
24212 8 }
24213 182 }
24214
24215 2108 attackclk = charging = spins = tapping = 0;
24216 2108 attack = none;
24217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2108 times.
2108 if ( warp_sound > 0 ) warpsfx = warp_sound;
24218 2108 warp_sound = 0;
24219 2108 word wdmap=0;
24220 2108 byte wscr=0,wtype=0,t=0;
24221 2108 bool overlay=false;
24222 2108 t=(currscr<128)?0:1;
24223 2108 int32_t wrindex = 0;
24224 2108 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
24225
24226 // Drawing commands probably shouldn't carry over...
24227
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 2041 times.
2108 if ( !get_bit(quest_rules,qr_SCRIPTDRAWSINWARPS) )
24228 2041 script_drawing_commands.Clear();
24229
24230
4/6
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 1223 times.
✓ Branch 2 taken 752 times.
✓ Branch 3 taken 66 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2108 switch(type)
24231 {
24232 case 0: // tile warp
24233 1223 wtype = tmpscr[t].tilewarptype[index];
24234 1223 wdmap = tmpscr[t].tilewarpdmap[index];
24235 1223 wscr = tmpscr[t].tilewarpscr[index];
24236 1223 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
24237 1223 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
24238 1223 break;
24239
24240 case 1: // side warp
24241 752 wtype = tmpscr[t].sidewarptype[index];
24242 752 wdmap = tmpscr[t].sidewarpdmap[index];
24243 752 wscr = tmpscr[t].sidewarpscr[index];
24244 752 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
24245 752 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
24246 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
24247 //there is no doscript for screen scripts. They run like ffcs.
24248
24249 752 break;
24250
24251 case 2: // whistle warp
24252 {
24253 66 wtype = wtWHISTLE;
24254
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
24255 66 int32_t level=0;
24256
24257
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(blowcnt==0)
24258 level = selectWlevel(0);
24259 else
24260 {
24261
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 66 times.
133 for(int32_t i=0; i<abs(blowcnt); i++)
24262 67 level = selectWlevel(blowcnt);
24263 }
24264
24265
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
24266 {
24267 level %= QMisc.warp[wind].size;
24268 game->set_wlevel(level);
24269 }
24270
24271 66 wdmap = QMisc.warp[wind].dmap[level];
24272 66 wscr = QMisc.warp[wind].scr[level];
24273 }
24274 66 break;
24275
24276 case 3:
24277 wtype = wtIWARP;
24278 wdmap = cheat_goto_dmap;
24279 wscr = cheat_goto_screen;
24280 break;
24281
24282 case 4:
24283 wtype = wtIWARP;
24284 wdmap = currdmap;
24285 wscr = homescr-DMaps[currdmap].xoff;
24286 break;
24287 }
24288
24289 2108 bool intradmap = (wdmap == currdmap);
24290 2108 int32_t olddmap = currdmap;
24291 2108 rehydratelake(type!=wtSCROLL);
24292
24293
6/8
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 450 times.
✓ Branch 3 taken 228 times.
✓ Branch 4 taken 423 times.
✓ Branch 5 taken 249 times.
✓ Branch 6 taken 66 times.
✗ Branch 7 not taken.
2108 switch(wtype)
24294 {
24295 case wtCAVE:
24296 {
24297 // cave/item room
24298 450 ALLOFF();
24299 450 homescr=currscr;
24300 450 currscr=0x80;
24301
24302
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 111 times.
450 if(DMaps[currdmap].flags&dmfCAVES) // cave
24303 {
24304 339 music_stop();
24305 339 kill_sfx();
24306
24307
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 278 times.
339 if(tmpscr->room==rWARP)
24308 {
24309 61 currscr=0x81;
24310 61 specialcave = STAIRCAVE;
24311 61 }
24312 278 else specialcave = GUYCAVE;
24313
24314 //lighting(2,dir);
24315 339 lighting(false, true);
24316 339 loadlvlpal(10);
24317
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 38 times.
640 bool b2 = COOLSCROLL&&
24318
3/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
301 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
24319
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
24320
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
24321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
24322 339 blackscr(30,b2?false:true);
24323 339 loadscr(0,wdmap,currscr,up,false);
24324 339 loadscr(1,wdmap,homescr,up,false);
24325 //preloaded freeform combos
24326 339 ffscript_engine(true);
24327 339 putscr(scrollbuf,0,0,tmpscr);
24328 339 putscrdoors(scrollbuf,0,0,tmpscr);
24329 339 dir=up;
24330 339 x=112;
24331 339 y=160;
24332
1/2
✓ Branch 0 taken 339 times.
✗ Branch 1 not taken.
339 if(didpit)
24333 {
24334 didpit=false;
24335 x=pitx;
24336 y=pity;
24337 }
24338
24339 339 reset_hookshot();
24340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if(reposition_sword_postwarp)
24341 {
24342 weapon *swd=NULL;
24343 for(int32_t i=0; i<Lwpns.Count(); i++)
24344 {
24345 swd = (weapon*)Lwpns.spr(i);
24346
24347 if(swd->id == (attack==wSword ? wSword : wWand))
24348 {
24349 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24350 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24351 positionSword(swd,item_id);
24352 break;
24353 }
24354 }
24355 }
24356 339 stepforward(diagonalMovement?5:6, false);
24357 339 }
24358 else // item room
24359 {
24360 111 specialcave = ITEMCELLAR;
24361 111 map_bkgsfx(false);
24362 111 kill_enemy_sfx();
24363 111 draw_screen(tmpscr,false);
24364
24365 //unless the room is already dark, fade to black
24366
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 110 times.
111 if(!darkroom)
24367 {
24368 110 darkroom = true;
24369 110 fade(DMaps[currdmap].color,true,false);
24370 110 }
24371
24372 111 blackscr(30,true);
24373 111 loadscr(0,wdmap,currscr,down,false);
24374 111 loadscr(1,wdmap,homescr,-1,false);
24375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( dontdraw < 2 ) { dontdraw=1; }
24376 111 draw_screen(tmpscr);
24377 111 fade(11,true,true);
24378 111 darkroom = false;
24379 111 dir=down;
24380 111 x=48;
24381 111 y=0;
24382
24383 // is this didpit check necessary?
24384
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(didpit)
24385 {
24386 didpit=false;
24387 x=pitx;
24388 y=pity;
24389 }
24390
24391 111 reset_hookshot();
24392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(reposition_sword_postwarp)
24393 {
24394 weapon *swd=NULL;
24395 for(int32_t i=0; i<Lwpns.Count(); i++)
24396 {
24397 swd = (weapon*)Lwpns.spr(i);
24398
24399 if(swd->id == (attack==wSword ? wSword : wWand))
24400 {
24401 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24402 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24403 positionSword(swd,item_id);
24404 break;
24405 }
24406 }
24407 }
24408 111 lighting(false, true);
24409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( dontdraw < 2 ) { dontdraw=0; }
24410 111 stepforward(diagonalMovement?16:18, false);
24411 }
24412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if (get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC)) playLevelMusic();
24413 450 break;
24414 }
24415
24416 case wtPASS: // passageway
24417 {
24418 228 map_bkgsfx(false);
24419 228 kill_enemy_sfx();
24420 228 ALLOFF();
24421 //play sound
24422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
24423 228 homescr=currscr;
24424 228 currscr=0x81;
24425 228 specialcave = PASSAGEWAY;
24426 228 byte warpscr2 = wscr + DMaps[wdmap].xoff;
24427 228 draw_screen(tmpscr,false);
24428
24429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(!get_bit(quest_rules, qr_NEW_DARKROOM))
24430 {
24431
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 220 times.
228 if(!darkroom)
24432 220 fade(DMaps[currdmap].color,true,false);
24433
24434 228 darkroom=true;
24435 228 }
24436 228 blackscr(30,true);
24437 228 loadscr(0,wdmap,currscr,down,false);
24438 228 loadscr(1,wdmap,homescr,-1,false);
24439 //preloaded freeform combos
24440 228 ffscript_engine(true);
24441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if ( dontdraw < 2 ) { dontdraw=1; }
24442 228 draw_screen(tmpscr);
24443 228 lighting(false, true);
24444 228 dir=down;
24445 228 x=48;
24446
24447
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 117 times.
228 if((homescr&15) > (warpscr2&15))
24448 {
24449 117 x=192;
24450 117 }
24451
24452
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4 times.
228 if((homescr&15) == (warpscr2&15))
24453 {
24454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((currscr>>4) > (warpscr2>>4))
24455 {
24456 4 x=192;
24457 4 }
24458 4 }
24459
24460 // is this didpit check necessary?
24461
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(didpit)
24462 {
24463 didpit=false;
24464 x=pitx;
24465 y=pity;
24466 }
24467
24468 228 y=0;
24469 228 set_respawn_point();
24470 228 trySideviewLadder();
24471 228 reset_hookshot();
24472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(reposition_sword_postwarp)
24473 {
24474 weapon *swd=NULL;
24475 for(int32_t i=0; i<Lwpns.Count(); i++)
24476 {
24477 swd = (weapon*)Lwpns.spr(i);
24478
24479 if(swd->id == (attack==wSword ? wSword : wWand))
24480 {
24481 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24482 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24483 positionSword(swd,item_id);
24484 break;
24485 }
24486 }
24487 }
24488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if ( dontdraw < 2 ) { dontdraw=0; }
24489 228 stepforward(diagonalMovement?16:18, false);
24490 228 newscr_clk=frame;
24491 228 activated_timed_warp=false;
24492 228 stepoutindex=index;
24493 228 stepoutscr = warpscr2;
24494 228 stepoutdmap = wdmap;
24495 228 stepoutwr=wrindex;
24496 }
24497 228 break;
24498
24499 case wtEXIT: // entrance/exit
24500 {
24501 423 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
24502 423 ALLOFF();
24503 423 music_stop();
24504 423 kill_sfx();
24505 423 blackscr(30,false);
24506 423 bool changedlevel = false;
24507 423 bool changeddmap = false;
24508
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 422 times.
423 if(currdmap != wdmap)
24509 {
24510 422 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24511 422 changeddmap = true;
24512 422 }
24513
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 405 times.
423 if(dlevel != DMaps[wdmap].level)
24514 {
24515 405 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24516 405 changedlevel = true;
24517 405 }
24518 423 dlevel = DMaps[wdmap].level;
24519 423 currdmap = wdmap;
24520
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 422 times.
423 if(changeddmap)
24521 {
24522 422 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24523 422 }
24524
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 405 times.
423 if(changedlevel)
24525 {
24526 405 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24527 405 }
24528
24529 423 currmap=DMaps[currdmap].map;
24530 423 init_dmap();
24531 423 update_subscreens(wdmap);
24532 423 loadfullpal();
24533 423 ringcolor(false);
24534 423 loadlvlpal(DMaps[currdmap].color);
24535 //lastentrance_dmap = currdmap;
24536 423 homescr = currscr = wscr + DMaps[currdmap].xoff;
24537 423 loadscr(0,currdmap,currscr,-1,overlay);
24538
24539
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 420 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
423 if((tmpscr->flags&fDARK) && !get_bit(quest_rules,qr_NEW_DARKROOM))
24540 {
24541
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules,qr_FADE))
24542 {
24543 interpolatedfade();
24544 }
24545 else
24546 {
24547 3 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
24548 }
24549
24550 3 darkroom=naturaldark=true;
24551 3 }
24552 else
24553 {
24554 420 darkroom=naturaldark=false;
24555 }
24556
24557 int32_t wrx,wry;
24558
24559
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 409 times.
423 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24560 {
24561 14 wrx=tmpscr->warpreturnx[0];
24562 14 wry=tmpscr->warpreturny[0];
24563 14 }
24564 else
24565 {
24566 409 wrx=tmpscr->warparrivalx;
24567 409 wry=tmpscr->warparrivaly;
24568 }
24569
24570
6/6
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 355 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 371 times.
423 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
24571 {
24572
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 141 times.
371 if(dlevel)
24573 {
24574 230 lastentrance = currscr;
24575 230 }
24576 else
24577 {
24578 141 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
24579 }
24580
24581 371 lastentrance_dmap = wdmap;
24582 371 }
24583
24584
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 193 times.
423 if(dlevel)
24585 {
24586
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 223 times.
230 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24587 {
24588 7 x=tmpscr->warpreturnx[wrindex];
24589 7 y=tmpscr->warpreturny[wrindex];
24590 7 }
24591 else
24592 {
24593 223 x=tmpscr->warparrivalx;
24594 223 y=tmpscr->warparrivaly;
24595 }
24596 230 }
24597 else
24598 {
24599 193 x=tmpscr->warpreturnx[wrindex];
24600 193 y=tmpscr->warpreturny[wrindex];
24601 }
24602
24603
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 4 times.
423 if(didpit)
24604 {
24605 4 didpit=false;
24606 4 x=pitx;
24607 4 y=pity;
24608 4 }
24609
24610 423 dir=down;
24611
24612
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 407 times.
423 if(x==0) dir=right;
24613
24614
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 412 times.
423 if(x==240) dir=left;
24615
24616
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 409 times.
423 if(y==0) dir=down;
24617
24618
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 252 times.
423 if(y==160) dir=up;
24619
24620
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 193 times.
423 if(dlevel)
24621 {
24622 // reset enemy kill counts
24623
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 230 times.
29670 for(int32_t i=0; i<128; i++)
24624 {
24625 29440 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
24626 29440 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
24627 29440 }
24628 230 }
24629
24630 423 markBmap(dir^1);
24631 //preloaded freeform combos
24632 423 ffscript_engine(true);
24633
24634 423 reset_hookshot();
24635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(reposition_sword_postwarp)
24636 {
24637 weapon *swd=NULL;
24638 for(int32_t i=0; i<Lwpns.Count(); i++)
24639 {
24640 swd = (weapon*)Lwpns.spr(i);
24641
24642 if(swd->id == (attack==wSword ? wSword : wWand))
24643 {
24644 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24645 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24646 positionSword(swd,item_id);
24647 break;
24648 }
24649 }
24650 }
24651
24652
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 266 times.
423 if(isdungeon())
24653 {
24654 157 openscreen();
24655
3/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 123 times.
157 if(get_bit(extra_rules, er_SHORTDGNWALK)==0 && get_bit(quest_rules, qr_SHORTDGNWALK)==0)
24656 123 stepforward(diagonalMovement?11:12, false);
24657 else
24658 // Didn't walk as far pre-1.93, and some quests depend on that
24659 34 stepforward(8, false);
24660 157 }
24661 else
24662 {
24663
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 243 times.
266 if(!COOLSCROLL)
24664 23 openscreen();
24665
24666 266 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
24667 266 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
24668 266 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
24669
24670
5/10
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 178 times.
✓ Branch 4 taken 178 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 178 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
266 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
24671 {
24672 88 reset_pal_cycling();
24673 88 putscr(scrollbuf,0,0,tmpscr);
24674 88 putscrdoors(scrollbuf,0,0,tmpscr);
24675 88 walkup(COOLSCROLL);
24676 88 }
24677
5/10
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
✓ Branch 4 taken 175 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 175 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
178 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
24678 {
24679 3 reset_pal_cycling();
24680 3 putscr(scrollbuf,0,0,tmpscr);
24681 3 putscrdoors(scrollbuf,0,0,tmpscr);
24682 3 walkdown2(COOLSCROLL);
24683 3 }
24684
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 13 times.
175 else if(COOLSCROLL)
24685 {
24686 162 openscreen();
24687 162 }
24688 }
24689
24690 423 show_subscreen_life=true;
24691 423 show_subscreen_numbers=true;
24692 423 playLevelMusic();
24693 423 currcset=DMaps[currdmap].color;
24694 423 dointro();
24695 423 set_respawn_point();
24696 423 trySideviewLadder();
24697
24698
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 423 times.
2961 for(int32_t i=0; i<6; i++)
24699 2538 visited[i]=-1;
24700
24701 423 break;
24702 }
24703
24704 case wtSCROLL: // scrolling warp
24705 {
24706 249 int32_t c = DMaps[currdmap].color;
24707 249 scrolling_map = currmap;
24708 249 currmap = DMaps[wdmap].map;
24709 249 update_subscreens(wdmap);
24710
24711 249 dlevel = DMaps[wdmap].level;
24712 //check if Hero has the map for the new location before updating the subscreen. ? -Z
24713 //This works only in one direction, if Hero had a map, to not having one.
24714 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
24715 249 update_subscreens(wdmap);
24716
24717 /*if ( has_item(itype_map, dlevel) )
24718 {
24719 //Blank the map during an intra-dmap scrolling warp.
24720 dlevel = -1; //a hack for the minimap. This works!! -Z
24721 }*/
24722
24723 // fix the scrolling direction, if it was a tile or instant warp
24724
2/4
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
249 if(type==0 || type>=3)
24725 {
24726 sdir = dir;
24727 }
24728
24729 249 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
24730 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
24731
24732 249 reset_hookshot();
24733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
249 if(reposition_sword_postwarp)
24734 {
24735 weapon *swd=NULL;
24736 for(int32_t i=0; i<Lwpns.Count(); i++)
24737 {
24738 swd = (weapon*)Lwpns.spr(i);
24739
24740 if(swd->id == (attack==wSword ? wSword : wWand))
24741 {
24742 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24743 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24744 positionSword(swd,item_id);
24745 break;
24746 }
24747 }
24748 }
24749
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 203 times.
249 if(!intradmap)
24750 {
24751 203 homescr = currscr = wscr + DMaps[wdmap].xoff;
24752 203 init_dmap();
24753
24754 int32_t wrx,wry;
24755
24756
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 99 times.
203 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24757 {
24758 104 wrx=tmpscr->warpreturnx[0];
24759 104 wry=tmpscr->warpreturny[0];
24760 104 }
24761 else
24762 {
24763 99 wrx=tmpscr->warparrivalx;
24764 99 wry=tmpscr->warparrivaly;
24765 }
24766
24767
7/8
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 129 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 68 times.
203 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!get_bit(quest_rules,qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
24768 {
24769
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 48 times.
68 if(dlevel)
24770 {
24771 20 lastentrance = currscr;
24772 20 }
24773 else
24774 {
24775 48 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
24776 }
24777
24778 68 lastentrance_dmap = wdmap;
24779 68 }
24780 203 }
24781
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 114 times.
249 if(DMaps[currdmap].color != c)
24782 {
24783 114 lighting(false, true);
24784 114 }
24785
24786 249 playLevelMusic();
24787 249 currcset=DMaps[currdmap].color;
24788 249 dointro();
24789 }
24790 249 break;
24791
24792 case wtWHISTLE: // whistle warp
24793 {
24794 66 scrolling_map = currmap;
24795 66 currmap = DMaps[wdmap].map;
24796 66 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
24797 66 reset_hookshot();
24798 66 currdmap=wdmap;
24799 66 dlevel=DMaps[currdmap].level;
24800 66 lighting(false, true);
24801 66 init_dmap();
24802
24803 66 playLevelMusic();
24804 66 currcset=DMaps[currdmap].color;
24805 66 dointro();
24806 66 action=inwind; FFCore.setHeroAction(inwind);
24807 int32_t wry;
24808
24809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24810 wry=tmpscr->warpreturny[0];
24811 66 else wry=tmpscr->warparrivaly;
24812
24813 int32_t wrx;
24814
24815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24816 wrx=tmpscr->warpreturnx[0];
24817 66 else wrx=tmpscr->warparrivalx;
24818
24819
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 66 times.
✓ Branch 10 taken 66 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 66 times.
✗ Branch 13 not taken.
132 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
24820
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
66 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
24821 66 whirlwind=255;
24822 66 whistleitem=-1;
24823 }
24824 66 break;
24825
24826 case wtIWARP:
24827 case wtIWARPBLK:
24828 case wtIWARPOPEN:
24829 case wtIWARPZAP:
24830 case wtIWARPWAVE: // insta-warps
24831 {
24832 692 bool old_192 = false;
24833
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if (get_bit(quest_rules,qr_192b163_WARP))
24834 {
24835 if ( wtype == wtIWARPWAVE )
24836 {
24837 wtype = wtIWARPWAVE;
24838 old_192 = true;
24839 }
24840 if ( old_192 )
24841 {
24842 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
24843 didpit=false;
24844 update_subscreens();
24845 warp_sound = 0;
24846 is_warping = false;
24847 return false;
24848 }
24849 }
24850 //for determining whether to exit cave
24851 692 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
24852 692 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
24853 692 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
24854
24855
8/8
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 596 times.
✓ Branch 4 taken 617 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 604 times.
1338 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
24856
8/8
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 592 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 604 times.
✓ Branch 6 taken 592 times.
✓ Branch 7 taken 12 times.
617 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
24857
24858
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 625 times.
776 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
24859 {
24860 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
24861 625 bool wasswimming = (action == swimming);
24862 625 int32_t olddiveclk = diveclk;
24863 625 ALLOFF();
24864
24865
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 18 times.
625 if(wasswimming)
24866 {
24867 18 Hero.SetSwim();
24868 18 diveclk = olddiveclk;
24869 18 }
24870
24871 625 kill_sfx();
24872 625 }
24873 //play sound
24874
2/2
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 42 times.
626 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
24875
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 555 times.
624 if(wtype==wtIWARPZAP)
24876 {
24877 69 zapout();
24878 69 }
24879
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 517 times.
555 else if(wtype==wtIWARPWAVE)
24880 {
24881 //only draw Hero if he's not in a cave -DD
24882 38 wavyout(!cavewarp);
24883 38 }
24884
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 175 times.
517 else if(wtype!=wtIWARP)
24885 {
24886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175 times.
175 bool b2 = COOLSCROLL&&cavewarp;
24887 175 blackscr(30,b2?false:true);
24888 175 }
24889
24890 624 int32_t c = DMaps[currdmap].color;
24891 624 bool changedlevel = false;
24892 624 bool changeddmap = false;
24893
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 368 times.
624 if(currdmap != wdmap)
24894 {
24895 368 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24896 368 changeddmap = true;
24897 368 }
24898
2/2
✓ Branch 0 taken 458 times.
✓ Branch 1 taken 166 times.
624 if(dlevel != DMaps[wdmap].level)
24899 {
24900 166 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24901 166 changedlevel = true;
24902 166 }
24903 624 dlevel = DMaps[wdmap].level;
24904 624 currdmap = wdmap;
24905
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 368 times.
624 if(changeddmap)
24906 {
24907 368 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24908 368 }
24909
2/2
✓ Branch 0 taken 458 times.
✓ Branch 1 taken 166 times.
624 if(changedlevel)
24910 {
24911 166 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24912 166 }
24913
24914 624 currmap = DMaps[currdmap].map;
24915 624 init_dmap();
24916 624 update_subscreens(wdmap);
24917
24918 624 ringcolor(false);
24919
24920
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 269 times.
624 if(DMaps[currdmap].color != c)
24921 269 loadlvlpal(DMaps[currdmap].color);
24922
24923 624 homescr = currscr = wscr + DMaps[currdmap].xoff;
24924
24925 624 lightingInstant(); // Also sets naturaldark
24926
24927 624 loadscr(0,currdmap,currscr,-1,overlay);
24928
24929 624 x = tmpscr->warpreturnx[wrindex];
24930 624 y = tmpscr->warpreturny[wrindex];
24931
24932
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 237 times.
624 if(didpit)
24933 {
24934 237 didpit=false;
24935 237 x=pitx;
24936 237 y=pity;
24937 237 }
24938
24939 624 type1 = combobuf[MAPCOMBO(x,y-16)].type;
24940 624 type2 = combobuf[MAPCOMBO(x,y)].type;
24941 624 type3 = combobuf[MAPCOMBO(x,y+16)].type;
24942
24943
2/2
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 73 times.
624 if(x==0) dir=right;
24944
24945
2/2
✓ Branch 0 taken 622 times.
✓ Branch 1 taken 2 times.
624 if(x==240) dir=left;
24946
24947
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 24 times.
624 if(y==0) dir=down;
24948
24949
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 29 times.
624 if(y==160) dir=up;
24950
24951 624 markBmap(dir^1);
24952
24953 624 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
24954
24955
10/16
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 14 times.
✓ Branch 12 taken 14 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
✓ Branch 15 taken 610 times.
638 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
24956 {
24957 14 hopclk=0xFF;
24958 14 SetSwim();
24959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (!IsSideSwim()) attackclk = charging = spins = 0;
24960 14 }
24961 else
24962 {
24963 610 action = none; FFCore.setHeroAction(none);
24964 }
24965 //preloaded freeform combos
24966 624 ffscript_engine(true);
24967
24968 624 putscr(scrollbuf,0,0,tmpscr);
24969 624 putscrdoors(scrollbuf,0,0,tmpscr);
24970
24971
10/10
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 596 times.
✓ Branch 4 taken 620 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 23 times.
✓ Branch 7 taken 597 times.
✓ Branch 8 taken 42 times.
✓ Branch 9 taken 65 times.
624 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
24972 {
24973 94 reset_pal_cycling();
24974 94 putscr(scrollbuf,0,0,tmpscr);
24975 94 putscrdoors(scrollbuf,0,0,tmpscr);
24976 94 walkup(COOLSCROLL);
24977 94 }
24978
9/10
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 599 times.
✓ Branch 4 taken 620 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 599 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 21 times.
662 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
24979 {
24980 84 reset_pal_cycling();
24981 84 putscr(scrollbuf,0,0,tmpscr);
24982 84 putscrdoors(scrollbuf,0,0,tmpscr);
24983 84 walkdown2(COOLSCROLL);
24984 84 }
24985
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 550 times.
620 else if(wtype==wtIWARPZAP)
24986 {
24987 70 zapin();
24988 70 }
24989
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 512 times.
550 else if(wtype==wtIWARPWAVE)
24990 {
24991 38 wavyin();
24992 38 }
24993
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 82 times.
512 else if(wtype==wtIWARPOPEN)
24994 {
24995 82 openscreen();
24996 82 }
24997
1/2
✓ Branch 0 taken 714 times.
✗ Branch 1 not taken.
714 if(reposition_sword_postwarp)
24998 {
24999 weapon *swd=NULL;
25000 for(int32_t i=0; i<Lwpns.Count(); i++)
25001 {
25002 swd = (weapon*)Lwpns.spr(i);
25003
25004 if(swd->id == (attack==wSword ? wSword : wWand))
25005 {
25006 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25007 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25008 positionSword(swd,item_id);
25009 break;
25010 }
25011 }
25012 }
25013 714 show_subscreen_life=true;
25014 714 show_subscreen_numbers=true;
25015 714 playLevelMusic();
25016 714 currcset=DMaps[currdmap].color;
25017 714 dointro();
25018 714 set_respawn_point();
25019 714 trySideviewLadder();
25020 }
25021 714 break;
25022
25023
25024 case wtNOWARP:
25025 {
25026 bool old_192 = false;
25027 if (get_bit(quest_rules,qr_192b163_WARP))
25028 {
25029 wtype = wtIWARPWAVE;
25030 old_192 = true;
25031 }
25032 if ( old_192 )
25033 {
25034 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
25035 //for determining whether to exit cave
25036 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
25037 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25038 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
25039
25040 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
25041 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
25042
25043 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
25044 {
25045 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
25046 bool wasswimming = (action == swimming);
25047 int32_t olddiveclk = diveclk;
25048 ALLOFF();
25049
25050 if(wasswimming)
25051 {
25052 Hero.SetSwim();
25053 diveclk = olddiveclk;
25054 }
25055
25056 kill_sfx();
25057 }
25058 //play sound
25059 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
25060 if(wtype==wtIWARPZAP)
25061 {
25062 zapout();
25063 }
25064 else if(wtype==wtIWARPWAVE)
25065 {
25066 //only draw Hero if he's not in a cave -DD
25067 wavyout(!cavewarp);
25068 }
25069 else if(wtype!=wtIWARP)
25070 {
25071 bool b2 = COOLSCROLL&&cavewarp;
25072 blackscr(30,b2?false:true);
25073 }
25074
25075 int32_t c = DMaps[currdmap].color;
25076 bool changedlevel = false;
25077 bool changeddmap = false;
25078 if(currdmap != wdmap)
25079 {
25080 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25081 changeddmap = true;
25082 }
25083 if(dlevel != DMaps[wdmap].level)
25084 {
25085 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25086 changedlevel = true;
25087 }
25088 dlevel = DMaps[wdmap].level;
25089 currdmap = wdmap;
25090 if(changeddmap)
25091 {
25092 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25093 }
25094 if(changedlevel)
25095 {
25096 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25097 }
25098 currmap = DMaps[currdmap].map;
25099 init_dmap();
25100 update_subscreens(wdmap);
25101
25102 ringcolor(false);
25103
25104 if(DMaps[currdmap].color != c)
25105 loadlvlpal(DMaps[currdmap].color);
25106
25107 homescr = currscr = wscr + DMaps[currdmap].xoff;
25108
25109 lightingInstant(); // Also sets naturaldark
25110
25111 loadscr(0,currdmap,currscr,-1,overlay);
25112
25113 x = tmpscr->warpreturnx[wrindex];
25114 y = tmpscr->warpreturny[wrindex];
25115
25116 if(didpit)
25117 {
25118 didpit=false;
25119 x=pitx;
25120 y=pity;
25121 }
25122
25123 type1 = combobuf[MAPCOMBO(x,y-16)].type;
25124 type2 = combobuf[MAPCOMBO(x,y)].type;
25125 type3 = combobuf[MAPCOMBO(x,y+16)].type;
25126
25127 if(x==0) dir=right;
25128
25129 if(x==240) dir=left;
25130
25131 if(y==0) dir=down;
25132
25133 if(y==160) dir=up;
25134
25135 markBmap(dir^1);
25136
25137 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
25138 {
25139 hopclk=0xFF;
25140 SetSwim();
25141 if (!IsSideSwim()) attackclk = charging = spins = 0;
25142 }
25143 else
25144 {
25145 action = none;
25146 FFCore.setHeroAction(none);
25147 }
25148 //preloaded freeform combos
25149 ffscript_engine(true);
25150
25151 putscr(scrollbuf,0,0,tmpscr);
25152 putscrdoors(scrollbuf,0,0,tmpscr);
25153
25154 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25155 {
25156 reset_pal_cycling();
25157 putscr(scrollbuf,0,0,tmpscr);
25158 putscrdoors(scrollbuf,0,0,tmpscr);
25159 walkup(COOLSCROLL);
25160 }
25161 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25162 {
25163 reset_pal_cycling();
25164 putscr(scrollbuf,0,0,tmpscr);
25165 putscrdoors(scrollbuf,0,0,tmpscr);
25166 walkdown2(COOLSCROLL);
25167 }
25168 else if(wtype==wtIWARPZAP)
25169 {
25170 zapin();
25171 }
25172 else if(wtype==wtIWARPWAVE)
25173 {
25174 wavyin();
25175 }
25176 else if(wtype==wtIWARPOPEN)
25177 {
25178 openscreen();
25179 }
25180 if(reposition_sword_postwarp)
25181 {
25182 weapon *swd=NULL;
25183 for(int32_t i=0; i<Lwpns.Count(); i++)
25184 {
25185 swd = (weapon*)Lwpns.spr(i);
25186
25187 if(swd->id == (attack==wSword ? wSword : wWand))
25188 {
25189 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25190 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25191 positionSword(swd,item_id);
25192 break;
25193 }
25194 }
25195 }
25196 show_subscreen_life=true;
25197 show_subscreen_numbers=true;
25198 playLevelMusic();
25199 currcset=DMaps[currdmap].color;
25200 dointro();
25201 set_respawn_point();
25202 trySideviewLadder();
25203 break;
25204 }
25205 else
25206 {
25207 if(reposition_sword_postwarp)
25208 {
25209 weapon *swd=NULL;
25210 for(int32_t i=0; i<Lwpns.Count(); i++)
25211 {
25212 swd = (weapon*)Lwpns.spr(i);
25213
25214 if(swd->id == (attack==wSword ? wSword : wWand))
25215 {
25216 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25217 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25218 positionSword(swd,item_id);
25219 break;
25220 }
25221 }
25222 }
25223 didpit=false;
25224 update_subscreens();
25225 warp_sound = 0;
25226 is_warping = false;
25227 return false;
25228 }
25229 }
25230 default:
25231 didpit=false;
25232 update_subscreens();
25233 warp_sound = 0;
25234 is_warping = false;
25235 if(reposition_sword_postwarp)
25236 {
25237 weapon *swd=NULL;
25238 for(int32_t i=0; i<Lwpns.Count(); i++)
25239 {
25240 swd = (weapon*)Lwpns.spr(i);
25241
25242 if(swd->id == (attack==wSword ? wSword : wWand))
25243 {
25244 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25245 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25246 positionSword(swd,item_id);
25247 break;
25248 }
25249 }
25250 }
25251 return false;
25252 }
25253
25254
25255
25256 // Stop Hero from drowning!
25257
5/6
✓ Branch 0 taken 2040 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 2040 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 1950 times.
2130 if(action==drowning || action==lavadrowning || action==sidedrowning)
25258 {
25259 180 drownclk=0;
25260 180 drownclk=0;
25261 180 action=none; FFCore.setHeroAction(none);
25262 180 }
25263
25264 1950 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
25265 // But keep him swimming if he ought to be!
25266 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
25267
9/12
✓ Branch 0 taken 2034 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 2006 times.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 28 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 2109 times.
✓ Branch 11 taken 17 times.
1978 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_bit(quest_rules,qr_DROWN))
25268 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
25269
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
28 && (action!=inwind))
25270 {
25271 17 hopclk=0xFF;
25272 17 SetSwim();
25273 17 }
25274
25275 2126 newscr_clk=frame;
25276 2126 activated_timed_warp=false;
25277 2126 eat_buttons();
25278
25279
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 1698 times.
2126 if(wtype!=wtIWARP)
25280 1698 attackclk=0;
25281
25282 2126 didstuff=0;
25283 2126 usecounts.clear();
25284 2126 map_bkgsfx(true);
25285 2126 loadside=dir^1;
25286 2126 whistleclk=-1;
25287
25288
3/4
✓ Branch 0 taken 2040 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 2130 times.
✗ Branch 3 not taken.
2126 if((z>0 || fakez>0) && isSideViewHero())
25289 {
25290 y-=z;
25291 y-=fakez;
25292 fakez=0;
25293 z=0;
25294 }
25295
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1925 times.
2130 else if(!isSideViewHero())
25296 {
25297 1925 fall=0;
25298 1925 fakefall=0;
25299 1925 }
25300
25301 // If warping between top-down and sideview screens,
25302 // fix enemies that are carried over by Full Screen Warp
25303 2130 const bool tmpscr_is_sideview = isSideViewHero();
25304
25305
4/4
✓ Branch 0 taken 1927 times.
✓ Branch 1 taken 203 times.
✓ Branch 2 taken 1898 times.
✓ Branch 3 taken 29 times.
2130 if(!wasSideview && tmpscr_is_sideview)
25306 {
25307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 for(int32_t i=0; i<guys.Count(); i++)
25308 {
25309 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
25310 {
25311 guys.spr(i)->y -= guys.spr(i)->z;
25312 guys.spr(i)->y -= guys.spr(i)->fakez;
25313 guys.spr(i)->z = 0;
25314 guys.spr(i)->fakez = 0;
25315 }
25316
25317 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
25318 guys.spr(i)->yofs += 2;
25319 }
25320 29 }
25321
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 1988 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 27 times.
2101 else if(wasSideview && !tmpscr_is_sideview)
25322 {
25323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t i=0; i<guys.Count(); i++)
25324 {
25325 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
25326 guys.spr(i)->yofs -= 2;
25327 }
25328 27 }
25329
25330
6/6
✓ Branch 0 taken 1346 times.
✓ Branch 1 taken 784 times.
✓ Branch 2 taken 275 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 212 times.
✓ Branch 5 taken 79 times.
2130 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_bit(quest_rules, qr_DMAP_0_CONTINUE_BUG)))
25331 {
25332
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 726 times.
996 if(dlevel)
25333 {
25334 int32_t wrx,wry;
25335
25336
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 213 times.
240 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
25337 {
25338 27 wrx=tmpscr->warpreturnx[0];
25339 27 wry=tmpscr->warpreturny[0];
25340 27 }
25341 else
25342 {
25343 213 wrx=tmpscr->warparrivalx;
25344 213 wry=tmpscr->warparrivaly;
25345 }
25346
25347
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
240 if((wtype == wtEXIT)
25348
7/10
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 173 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
240 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))))
25349 {
25350
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
63 if(!(wtype==wtSCROLL)||!(get_bit(quest_rules,qr_NOSCROLLCONTINUE)))
25351 {
25352 63 game->set_continue_scrn(homescr);
25353 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
25354 63 }
25355 else if(currdmap != game->get_continue_dmap())
25356 {
25357 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25358 }
25359 63 }
25360 else
25361 {
25362
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 22 times.
177 if(currdmap != game->get_continue_dmap())
25363 {
25364 22 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25365 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
25366 22 }
25367 }
25368 240 }
25369 else
25370 {
25371 726 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25372 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
25373 }
25374
25375 966 game->set_continue_dmap(currdmap);
25376 966 lastentrance_dmap = currdmap;
25377 966 lastentrance = game->get_continue_scrn();
25378 //Z_message("continue_map = %d\n",game->get_continue_dmap());
25379 966 }
25380
25381
1/2
✓ Branch 0 taken 2116 times.
✗ Branch 1 not taken.
2116 if(tmpscr->flags4&fAUTOSAVE)
25382 {
25383 save_game(true,0);
25384 }
25385
25386
2/2
✓ Branch 0 taken 2104 times.
✓ Branch 1 taken 12 times.
2116 if(tmpscr->flags6&fCONTINUEHERE)
25387 {
25388 12 lastentrance_dmap = currdmap;
25389 12 lastentrance = homescr;
25390 12 }
25391
25392 2116 update_subscreens();
25393 2116 verifyBothWeapons();
25394
25395
2/2
✓ Branch 0 taken 1666 times.
✓ Branch 1 taken 450 times.
2116 if(wtype==wtCAVE)
25396 {
25397
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 111 times.
450 if(DMaps[currdmap].flags&dmfGUYCAVES)
25398 678 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
25399 339 (char *)moduledata.roomtype_names[tmpscr[1].room]);
25400 else
25401 111 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
25402 450 }
25403 3332 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
25404
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 1362 times.
3028 wtype==wtPASS ? "Passageway" :
25405
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 939 times.
2301 wtype==wtEXIT ? "Entrance/Exit" :
25406
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 690 times.
939 wtype==wtSCROLL ? "Scrolling Warp" :
25407 690 wtype==wtWHISTLE ? "Whistle Warp" :
25408 "Insta-Warp");
25409
25410 2116 eventlog_mapflags();
25411
1/2
✓ Branch 0 taken 2116 times.
✗ Branch 1 not taken.
2116 if(reposition_sword_postwarp)
25412 {
25413 weapon *swd=NULL;
25414 for(int32_t i=0; i<Lwpns.Count(); i++)
25415 {
25416 swd = (weapon*)Lwpns.spr(i);
25417
25418 if(swd->id == (attack==wSword ? wSword : wWand))
25419 {
25420 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25421 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25422 positionSword(swd,item_id);
25423 break;
25424 }
25425 }
25426 }
25427 2116 FFCore.clear_combo_scripts();
25428
4/4
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 819 times.
✓ Branch 3 taken 76 times.
2116 if (!intradmap || get_bit(quest_rules, qr_WARPS_RESTART_DMAPSCRIPT))
25429 {
25430 2040 FFScript::deallocateAllArrays(ScriptType::DMap, olddmap);
25431 2040 FFCore.initZScriptDMapScripts();
25432 2040 FFCore.initZScriptActiveSubscreenScript();
25433
1/2
✓ Branch 0 taken 2040 times.
✗ Branch 1 not taken.
2040 if(refresh_dmap_scrollscript)
25434 {
25435 run_scrolling_script_int(false); //Pre-waitdraw
25436 refresh_dmap_scrollscript = false;
25437 }
25438 2040 }
25439 2116 is_warping = false;
25440
1/2
✓ Branch 0 taken 2116 times.
✗ Branch 1 not taken.
2116 if(!get_bit(quest_rules,qr_SCROLLWARP_NO_RESET_FRAME))
25441 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
25442 2116 return true;
25443 2116 }
25444
25445 287 void HeroClass::exitcave()
25446 {
25447 287 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25448 287 currscr=homescr;
25449 287 loadscr(0,currdmap,currscr,255,false); // bogus direction
25450 287 x = tmpscr->warpreturnx[0];
25451 287 y = tmpscr->warpreturny[0];
25452
25453
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(didpit)
25454 {
25455 didpit=false;
25456 x=pitx;
25457 y=pity;
25458 }
25459
25460
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 15 times.
287 if(x+y == 0)
25461 15 x = y = 80;
25462
25463 287 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
25464 287 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25465 287 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
25466
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 268 times.
575 bool b = COOLSCROLL &&
25467
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 191 times.
268 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
25468
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 191 times.
191 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
25469
4/4
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 173 times.
191 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
25470
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 173 times.
✓ Branch 3 taken 5 times.
173 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
25471 307 ALLOFF();
25472 307 blackscr(30,b?false:true);
25473 307 ringcolor(false);
25474 307 loadlvlpal(DMaps[currdmap].color);
25475 307 lighting(false, true);
25476 307 music_stop();
25477 307 kill_sfx();
25478 307 putscr(scrollbuf,0,0,tmpscr);
25479 307 putscrdoors(scrollbuf,0,0,tmpscr);
25480
25481
9/10
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 211 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 206 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
307 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25482 {
25483 104 walkup(COOLSCROLL);
25484 104 }
25485
9/10
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 188 times.
✓ Branch 4 taken 193 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 188 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
211 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25486 {
25487 18 walkdown2(COOLSCROLL);
25488 18 }
25489
25490 315 show_subscreen_life=true;
25491 315 show_subscreen_numbers=true;
25492 315 playLevelMusic();
25493 315 currcset=DMaps[currdmap].color;
25494 315 dointro();
25495 315 newscr_clk=frame;
25496 315 activated_timed_warp=false;
25497 315 dir=down;
25498 315 set_respawn_point();
25499 315 eat_buttons();
25500 315 didstuff=0;
25501 315 usecounts.clear();
25502 315 map_bkgsfx(true);
25503 315 loadside=dir^1;
25504 315 }
25505
25506
25507 5783 void HeroClass::stepforward(int32_t steps, bool adjust)
25508 {
25509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5783 times.
5783 if ( FFCore.nostepforward ) return;
25510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5783 times.
5783 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
25511 5783 zfix tx=x; //temp x
25512 5783 zfix ty=y; //temp y
25513 5783 zfix tstep(0); //temp single step distance
25514 5783 zfix s(0); //calculated step distance for all steps
25515 5783 z3step=2;
25516 5783 int32_t sh=shiftdir;
25517 5783 shiftdir=-1;
25518
25519
2/2
✓ Branch 0 taken 98942 times.
✓ Branch 1 taken 5783 times.
104725 for(int32_t i=steps; i>0; --i)
25520 {
25521
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 98931 times.
98942 if(diagonalMovement)
25522 {
25523
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25524 {
25525 11 tstep = 1.5;
25526 11 }
25527 else
25528 {
25529 tstep=z3step;
25530 z3step=(z3step%2)+1;
25531 }
25532 11 }
25533 else
25534 {
25535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98931 times.
98931 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
25536 {
25537 tstep = 1.5;
25538 }
25539 else
25540 {
25541
2/2
✓ Branch 0 taken 55707 times.
✓ Branch 1 taken 43224 times.
98931 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
25542
25543
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 31402 times.
✓ Branch 2 taken 24305 times.
✓ Branch 3 taken 19261 times.
✓ Branch 4 taken 23963 times.
98931 switch(dir)
25544 {
25545 case up:
25546 31402 ty-=tstep;
25547 31402 break;
25548
25549 case down:
25550 24305 ty+=tstep;
25551 24305 break;
25552
25553 case left:
25554 19261 tx-=tstep;
25555 19261 break;
25556
25557 case right:
25558 23963 tx+=tstep;
25559 23963 break;
25560 }
25561 }
25562 }
25563
25564 98942 s+=tstep;
25565 98942 }
25566
25567 5783 z3step=2;
25568
25569 5783 x = x.getInt();
25570 5783 y = y.getInt();
25571
2/2
✓ Branch 0 taken 104629 times.
✓ Branch 1 taken 5783 times.
110412 while(s>=0)
25572 {
25573
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104617 times.
104629 if(diagonalMovement)
25574 {
25575
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
12 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
25576 {
25577 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25578 {
25579 walkable = false;
25580 shiftdir = -1;
25581 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25582 switch(tdir)
25583 {
25584 case left:
25585 --x;
25586 break;
25587 case right:
25588 ++x;
25589 break;
25590 case up:
25591 --y;
25592 break;
25593 case down:
25594 ++y;
25595 break;
25596 }
25597 }
25598 else
25599 {
25600 walkable=false;
25601 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25602 moveOld2(dir, 150);
25603 }
25604 }
25605 else
25606 {
25607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25608 {
25609 12 s-=1.5;
25610 12 }
25611 else
25612 {
25613 s-=z3step;
25614 }
25615 12 walkable=true;
25616 12 moveOld2(dir, 150);
25617 }
25618
25619 12 shiftdir=-1;
25620 12 }
25621 else
25622 {
25623
3/6
✓ Branch 0 taken 58990 times.
✓ Branch 1 taken 45627 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104617 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104617 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
25624 {
25625 walkable=false;
25626 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25627 switch(tdir)
25628 {
25629 case left:
25630 --x;
25631 break;
25632 case right:
25633 ++x;
25634 break;
25635 case up:
25636 --y;
25637 break;
25638 case down:
25639 ++y;
25640 break;
25641 }
25642 }
25643 else
25644 {
25645
2/4
✓ Branch 0 taken 104617 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104617 times.
104617 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25646 {
25647 s-=1.5;
25648 }
25649
2/2
✓ Branch 0 taken 58990 times.
✓ Branch 1 taken 45627 times.
104617 else if(dir<left)
25650 {
25651 58990 s-=lsteps[y.getInt()&7];
25652 58990 }
25653 else
25654 {
25655 45627 s-=lsteps[x.getInt()&7];
25656 }
25657
25658 104617 moveOld2(dir, 150);
25659 }
25660 }
25661
25662
2/2
✓ Branch 0 taken 98846 times.
✓ Branch 1 taken 5783 times.
104629 if(s<0)
25663 {
25664 // Not quite sure how this is actually supposed to work.
25665 // There have to be two cases for each direction or Hero
25666 // either walks too far onto the screen or may get stuck
25667 // going through walk-through walls.
25668
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2110 times.
✓ Branch 2 taken 1268 times.
✓ Branch 3 taken 1049 times.
✓ Branch 4 taken 1356 times.
5783 switch(dir)
25669 {
25670 case up:
25671
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1974 times.
2110 if(y<8) // Leaving the screen
25672 136 y+=s;
25673 else // Entering the screen
25674 1974 y-=s;
25675
25676 2110 break;
25677
25678 case down:
25679
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1153 times.
1268 if(y>152)
25680 115 y-=s;
25681 else
25682 1153 y+=s;
25683
25684 1268 break;
25685
25686 case left:
25687
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 948 times.
1049 if(x<8)
25688 101 x+=s;
25689 else
25690 948 x-=s;
25691
25692 1049 break;
25693
25694 case right:
25695
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1241 times.
1356 if(x>=232)
25696 115 x-=s;
25697 else
25698 1241 x+=s;
25699
25700 1356 break;
25701 }
25702 5783 }
25703
25704
25705 104629 draw_screen(tmpscr);
25706
1/2
✓ Branch 0 taken 104629 times.
✗ Branch 1 not taken.
104629 if (canSideviewLadder()) setOnSideviewLadder(true);
25707 104629 advanceframe(true);
25708
25709
1/2
✓ Branch 0 taken 104629 times.
✗ Branch 1 not taken.
104629 if(Quit)
25710 return;
25711 }
25712
4/4
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1356 times.
✓ Branch 2 taken 1268 times.
✓ Branch 3 taken 3159 times.
5783 if(dir==right||dir==down)
25713 {
25714 2624 x=int32_t(x);
25715 2624 y=int32_t(y);
25716 2624 }
25717 else
25718 {
25719 3159 x = x.getInt();
25720 3159 y = y.getInt();
25721 }
25722 5783 set_respawn_point();
25723 5783 draw_screen(tmpscr);
25724 5783 eat_buttons();
25725 5783 shiftdir=sh;
25726 5783 }
25727
25728 227 void HeroClass::walkdown(bool opening) //entering cave
25729 {
25730
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 197 times.
227 if(opening)
25731 {
25732 197 close_black_opening(x+8, y+8+playing_field_offset, false);
25733 197 }
25734
25735 227 hclk=0;
25736 227 stop_item_sfx(itype_brang);
25737 227 sfx(WAV_STAIRS,pan(x.getInt()));
25738 227 clk=0;
25739 // int32_t cmby=(y.getInt()&0xF0)+16;
25740 // Fix Hero's position to the grid
25741 227 y=y.getInt()&0xF0;
25742 227 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
25743 227 attack=wNone;
25744 227 attackid=-1;
25745 227 reset_swordcharge();
25746 227 climb_cover_x=x.getInt()&0xF0;
25747 227 climb_cover_y=(y.getInt()&0xF0)+16;
25748
25749 227 guys.clear();
25750 227 chainlinks.clear();
25751 227 Lwpns.clear();
25752 227 Ewpns.clear();
25753 227 items.clear();
25754
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 14528 times.
14755 for(int32_t i=0; i<64; i++)
25755 {
25756 14528 herostep();
25757
25758
2/4
✓ Branch 0 taken 14528 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14528 times.
14528 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25759 hero_count=(hero_count+1)%16;
25760
25761
2/2
✓ Branch 0 taken 10896 times.
✓ Branch 1 taken 3632 times.
14528 if((i&3)==3)
25762 3632 ++y;
25763
25764 14528 draw_screen(tmpscr);
25765 14528 advanceframe(true);
25766
25767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14528 times.
14528 if(Quit)
25768 break;
25769 14528 }
25770
25771 227 action=none; FFCore.setHeroAction(none);
25772 227 }
25773
25774 21 void HeroClass::walkdown2(bool opening) //exiting cave 2
25775 {
25776 21 int32_t type = combobuf[MAPCOMBO(x,y)].type;
25777
25778
25779 // Fix Hero's position to the grid
25780 21 y=y.getInt()&0xF0;
25781
25782
2/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
25783 y -= 16;
25784
25785 21 climb_cover_x=x.getInt()&0xF0;
25786 21 climb_cover_y=y.getInt()&0xF0;
25787
25788 21 dir=down;
25789 21 z=fakez=fall=fakefall=0;
25790
25791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(opening)
25792 {
25793 21 open_black_opening(x+8, y+8+playing_field_offset+16, false);
25794 21 }
25795
25796 21 hclk=0;
25797 21 stop_item_sfx(itype_brang);
25798 21 sfx(WAV_STAIRS,pan(x.getInt()));
25799 21 clk=0;
25800 21 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
25801 21 attack=wNone;
25802 21 attackid=-1;
25803 21 reset_swordcharge();
25804
25805 21 guys.clear();
25806 21 chainlinks.clear();
25807 21 Lwpns.clear();
25808 21 Ewpns.clear();
25809 21 items.clear();
25810
25811
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1344 times.
1365 for(int32_t i=0; i<64; i++)
25812 {
25813 1344 herostep();
25814
25815
2/4
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1344 times.
1344 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25816 hero_count=(hero_count+1)%16;
25817
25818
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 if((i&3)==3)
25819 336 ++y;
25820
25821 1344 draw_screen(tmpscr);
25822 1344 advanceframe(true);
25823
25824
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(Quit)
25825 break;
25826 1344 }
25827
25828
25829 21 action=none; FFCore.setHeroAction(none);
25830 21 }
25831
25832 196 void HeroClass::walkup(bool opening) //exiting cave
25833 {
25834 196 int32_t type = combobuf[MAPCOMBO(x,y)].type;
25835
25836
4/6
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 188 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
196 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
25837 y+=16;
25838
25839 // Fix Hero's position to the grid
25840 196 y=y.getInt()&0xF0;
25841 196 z=fakez=fall=fakefall=0;
25842
25843
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 174 times.
196 if(opening)
25844 {
25845 174 open_black_opening(x+8, y+8+playing_field_offset-16, false);
25846 174 }
25847
25848 196 hclk=0;
25849 196 stop_item_sfx(itype_brang);
25850 196 sfx(WAV_STAIRS,pan(x.getInt()));
25851 196 dir=down;
25852 196 clk=0;
25853 // int32_t cmby=y.getInt()&0xF0;
25854 196 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
25855 196 attack=wNone;
25856 196 attackid=-1;
25857 196 reset_swordcharge();
25858 196 climb_cover_x=x.getInt()&0xF0;
25859 196 climb_cover_y=y.getInt()&0xF0;
25860
25861 196 guys.clear();
25862 196 chainlinks.clear();
25863 196 Lwpns.clear();
25864 196 Ewpns.clear();
25865 196 items.clear();
25866
25867
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 12544 times.
12740 for(int32_t i=0; i<64; i++)
25868 {
25869 12544 herostep();
25870
25871
2/4
✓ Branch 0 taken 12544 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12544 times.
12544 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25872 hero_count=(hero_count+1)%16;
25873
25874
2/2
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 3136 times.
12544 if((i&3)==0)
25875 3136 --y;
25876
25877 12544 draw_screen(tmpscr);
25878 12544 advanceframe(true);
25879
25880
1/2
✓ Branch 0 taken 12544 times.
✗ Branch 1 not taken.
12544 if(Quit)
25881 break;
25882 12544 }
25883 196 map_bkgsfx(true);
25884 196 loadside=dir^1;
25885 196 action=none; FFCore.setHeroAction(none);
25886 196 }
25887
25888 114 void HeroClass::walkup2(bool opening) //entering cave2
25889 {
25890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(opening)
25891 {
25892 114 close_black_opening(x+8, y+8+playing_field_offset, false);
25893 114 }
25894
25895 114 hclk=0;
25896 114 stop_item_sfx(itype_brang);
25897 114 sfx(WAV_STAIRS,pan(x.getInt()));
25898 114 dir=up;
25899 114 clk=0;
25900 // int32_t cmby=y.getInt()&0xF0;
25901 114 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
25902 114 attack=wNone;
25903 114 attackid=-1;
25904 114 reset_swordcharge();
25905 114 climb_cover_x=x.getInt()&0xF0;
25906 114 climb_cover_y=(y.getInt()&0xF0)-16;
25907
25908 114 guys.clear();
25909 114 chainlinks.clear();
25910 114 Lwpns.clear();
25911 114 Ewpns.clear();
25912 114 items.clear();
25913
25914
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 7296 times.
7410 for(int32_t i=0; i<64; i++)
25915 {
25916 7296 herostep();
25917
25918
2/4
✓ Branch 0 taken 7296 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7296 times.
7296 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25919 hero_count=(hero_count+1)%16;
25920
25921
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 if((i&3)==0)
25922 1824 --y;
25923
25924 7296 draw_screen(tmpscr);
25925 7296 advanceframe(true);
25926
25927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7296 times.
7296 if(Quit)
25928 break;
25929 7296 }
25930 114 map_bkgsfx(true);
25931 114 loadside=dir^1;
25932 114 action=none; FFCore.setHeroAction(none);
25933 114 }
25934
25935 325 void HeroClass::stepout() // Step out of item cellars and passageways
25936 {
25937 325 int32_t sc = specialcave; // This gets erased by ALLOFF()
25938 325 ALLOFF();
25939 325 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25940 325 map_bkgsfx(false);
25941 325 kill_enemy_sfx();
25942 325 draw_screen(tmpscr,false);
25943 325 fade(sc>=GUYCAVE?10:11,true,false);
25944 325 blackscr(30,true);
25945 325 ringcolor(false);
25946
25947
4/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 142 times.
✓ Branch 3 taken 183 times.
325 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
25948 {
25949 183 currdmap=stepoutdmap;
25950 183 currmap=DMaps[currdmap].map;
25951 183 dlevel=DMaps[currdmap].level;
25952
25953 //we might have just left a passage, so be sure to update the CSet record -DD
25954 183 currcset=DMaps[currdmap].color;
25955
25956 183 init_dmap();
25957 183 homescr=stepoutscr;
25958 183 }
25959
25960 325 currscr=homescr;
25961 325 loadscr(0,currdmap,currscr,255,false); // bogus direction
25962 325 draw_screen(tmpscr,false);
25963
25964
3/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✓ Branch 3 taken 6 times.
325 if(get_bit(quest_rules, qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
25965 {
25966 319 darkroom = naturaldark = false;
25967 319 fade(DMaps[currdmap].color,true,true);
25968 319 }
25969 else
25970 {
25971 6 darkroom = naturaldark = true;
25972
25973
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if(get_bit(quest_rules,qr_FADE))
25974 {
25975 4 interpolatedfade();
25976 4 }
25977 else
25978 {
25979 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
25980 }
25981 6 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
25982 6 si+=3*48;
25983
25984
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<16; i++)
25985 {
25986 96 RAMpal[CSET(9)+i] = _RGB(si);
25987 96 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
25988 96 si+=3;
25989 96 }
25990 }
25991
25992 325 x = tmpscr->warpreturnx[stepoutwr];
25993 325 y = tmpscr->warpreturny[stepoutwr];
25994
25995
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 if(didpit)
25996 {
25997 didpit=false;
25998 x=pitx;
25999 y=pity;
26000 }
26001
26002
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 309 times.
325 if(x+y == 0)
26003 16 x = y = 80;
26004
26005 325 dir=down;
26006
26007 325 set_respawn_point();
26008
26009 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
26010 325 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
26011
26012
4/6
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 320 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
325 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
26013 {
26014 walkup(false);
26015 }
26016
4/6
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 320 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
325 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
26017 {
26018 walkdown2(false);
26019 }
26020
26021 325 newscr_clk=frame;
26022 325 activated_timed_warp=false;
26023 325 didstuff=0;
26024 325 usecounts.clear();
26025 325 eat_buttons();
26026 325 markBmap(-1);
26027 325 map_bkgsfx(true);
26028
26029
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 27 times.
325 if(!get_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC))
26030 {
26031 27 music_stop();
26032 27 playLevelMusic();
26033 27 }
26034
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 else if(get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC))
26035 {
26036 playLevelMusic();
26037 }
26038
26039 325 loadside=dir^1;
26040 325 }
26041
26042 12547 bool HeroClass::nextcombo_wf(int32_t d2)
26043 {
26044
6/8
✓ Branch 0 taken 12496 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 12250 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 12250 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 246 times.
✗ Branch 7 not taken.
12547 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
26045 12547 return false;
26046
26047 // assumes Hero is about to scroll screens
26048
26049 int32_t ns = nextscr(d2);
26050
26051 if(ns==0xFFFF)
26052 return false;
26053
26054 // want actual screen index, not game->maps[] index
26055 ns = (ns&127) + (ns>>7)*MAPSCRS;
26056
26057 int32_t cx = x;
26058 int32_t cy = y;
26059
26060 switch(d2)
26061 {
26062 case up:
26063 cy=160;
26064 break;
26065
26066 case down:
26067 cy=0;
26068 break;
26069
26070 case left:
26071 cx=240;
26072 break;
26073
26074 case right:
26075 cx=0;
26076 break;
26077 }
26078
26079 // check lower half of combo
26080 cy += 8;
26081
26082 // from MAPCOMBO()
26083 int32_t cmb = (cy&0xF0)+(cx>>4);
26084
26085 if(cmb>175)
26086 return true;
26087
26088 newcombo c = combobuf[TheMaps[ns].data[cmb]];
26089 bool dried = iswater_type(c.type) && DRIEDLAKE;
26090 bool swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
26091 int32_t b=1;
26092
26093 if(cx&8) b<<=2;
26094
26095 if(cy&8) b<<=1;
26096
26097 if((c.walk&b) && !dried && !swim)
26098 return true;
26099
26100 // next block (i.e. cnt==2)
26101 if(!(cx&8))
26102 {
26103 b<<=2;
26104 }
26105 else
26106 {
26107 c = combobuf[TheMaps[ns].data[++cmb]];
26108 dried = iswater_type(c.type) && DRIEDLAKE;
26109 swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
26110 b=1;
26111
26112 if(cy&8)
26113 {
26114 b<<=1;
26115 }
26116 }
26117
26118 return (c.walk&b) ? !dried && !swim : false;
26119 12547 }
26120
26121 bool HeroClass::nextcombo_solid(int32_t d2)
26122 {
26123 if(toogam || currscr>=128)
26124 return false;
26125
26126 // assumes Hero is about to scroll screens
26127
26128 int32_t ns = nextscr(d2);
26129
26130 if(ns==0xFFFF)
26131 return false;
26132
26133 // want actual screen index, not game->maps[] index
26134 ns = (ns&127) + (ns>>7)*MAPSCRS;
26135 int32_t screen = (ns%MAPSCRS);
26136 int32_t map = (ns - screen) / MAPSCRS;
26137
26138 int32_t cx = x;
26139 int32_t cy = y;
26140
26141 switch(d2)
26142 {
26143 case up:
26144 cy=160;
26145 break;
26146
26147 case down:
26148 cy=0;
26149 break;
26150
26151 case left:
26152 cx=240;
26153 break;
26154
26155 case right:
26156 cx=0;
26157 break;
26158 }
26159
26160 if(d2==up) cy += 8;
26161
26162 if(d2==left||d2==right) cy+=bigHitbox?0:8;
26163
26164 int32_t initcx = cx;
26165 int32_t initcy = cy;
26166 // from MAPCOMBO()
26167
26168 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
26169 {
26170 cx = initcx;
26171 for(int32_t k=0; k<=(get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
26172 {
26173 int32_t cmb = (cy&0xF0)+(cx>>4);
26174
26175 if(cmb>175)
26176 {
26177 return true;
26178 }
26179
26180 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))];
26181
26182 int32_t b=1;
26183
26184 if(cx&8) b<<=2;
26185
26186 if(cy&8) b<<=1;
26187
26188 //bool bridgedetected = false;
26189
26190 int32_t walk = c.walk;
26191 if (get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))
26192 {
26193 for (int32_t m = 0; m <= 1; m++)
26194 {
26195 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
26196 if (cmb.type == cBRIDGE)
26197 {
26198 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
26199 {
26200 int efflag = (cmb.walk & 0xF0)>>4;
26201 int newsolid = (cmb.walk & 0xF);
26202 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
26203 }
26204 else walk &= cmb.walk;
26205 }
26206 else walk |= cmb.walk;
26207 }
26208 }
26209 /*
26210 if (bridgedetected)
26211 {
26212 continue;
26213 }*/
26214
26215 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
26216 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
26217
26218 if((walk&b) && !swim)
26219 {
26220 return true;
26221 }
26222 }
26223
26224 /*
26225 #if 0
26226
26227 //
26228 // next block (i.e. cnt==2)
26229 if(!(cx&8))
26230 {
26231 b<<=2;
26232 }
26233 else
26234 {
26235 c = combobuf[TheMaps[ns].data[++cmb]];
26236 dried = iswater_type(c.type) && DRIEDLAKE;
26237 //swim = iswater_type(c.type) && (current_item(itype_flippers));
26238 b=1;
26239
26240 if(cy&8)
26241 {
26242 b<<=1;
26243 }
26244 }
26245
26246 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26247
26248 if((c.walk&b) && !dried && !swim)
26249 {
26250 return true;
26251 }
26252
26253 cx+=8;
26254
26255 if(cx&7)
26256 {
26257 if(!(cx&8))
26258 {
26259 b<<=2;
26260 }
26261 else
26262 {
26263 c = combobuf[TheMaps[ns].data[++cmb]];
26264 dried = iswater_type(c.type) && DRIEDLAKE;
26265 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26266 b=1;
26267
26268 if(cy&8)
26269 {
26270 b<<=1;
26271 }
26272 }
26273
26274 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26275
26276 if((c.walk&b) && !dried && !swim)
26277 return true;
26278 }
26279
26280 #endif
26281 */
26282 }
26283
26284 return false;
26285 }
26286
26287 6406154 void HeroClass::checkscroll()
26288 {
26289 //DO NOT scroll if Hero is vibrating due to Divine Escape effect -DD
26290
2/4
✓ Branch 0 taken 6406154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6406154 times.
✗ Branch 3 not taken.
6406154 if(action == casting||action==sideswimcasting)
26291 return;
26292
26293
2/2
✓ Branch 0 taken 6392748 times.
✓ Branch 1 taken 13406 times.
6406154 if(toogam)
26294 {
26295
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(x<0 && (currscr&15)==0) x=0;
26296
26297
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13386 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
13406 if(y<0 && currscr<16) y=0;
26298
26299
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13391 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
13406 if(x>240 && (currscr&15)==15) x=240;
26300
26301
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(y>160 && currscr>=112) y=160;
26302 13406 }
26303
26304
2/2
✓ Branch 0 taken 6402787 times.
✓ Branch 1 taken 3367 times.
6406154 if(y<0)
26305 {
26306 3367 bool doit=true;
26307 3367 y=0;
26308
26309
4/6
✓ Branch 0 taken 3366 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3366 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3365 times.
3367 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26310 doit = false;
26311
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3364 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
3365 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26312 doit = false;
26313
26314
1/2
✓ Branch 0 taken 3365 times.
✗ Branch 1 not taken.
3365 if(nextcombo_wf(up))
26315 doit=false;
26316
26317
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3365 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3365 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
26318 {
26319 if(nextcombo_solid(up))
26320 doit=false;
26321 }
26322
26323
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3365 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3365 if(doit || action==inwind)
26324 {
26325
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 3040 times.
3365 if(currscr>=128)
26326 {
26327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 325 times.
325 if(specialcave >= GUYCAVE)
26328 exitcave();
26329 325 else stepout();
26330 325 }
26331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3040 times.
3040 else if(action==inwind)
26332 {
26333 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26334 {
26335 action=none; FFCore.setHeroAction(none);
26336 restart_level();
26337 }
26338 else
26339 {
26340 dowarp(2,up);
26341 }
26342 }
26343
3/6
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2978 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3040 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26344 {
26345 62 sdir=up;
26346 62 dowarp(1,(tmpscr->sidewarpindex)&3);
26347 62 }
26348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2978 times.
2978 else if(!edge_of_dmap(up))
26349 {
26350 2978 scrolling_map = currmap;
26351 2978 scrollscr(up);
26352
26353
1/2
✓ Branch 0 taken 2978 times.
✗ Branch 1 not taken.
2978 if(tmpscr->flags4&fAUTOSAVE)
26354 {
26355 save_game(true,0);
26356 }
26357
26358
2/2
✓ Branch 0 taken 2974 times.
✓ Branch 1 taken 4 times.
2978 if(tmpscr->flags6&fCONTINUEHERE)
26359 {
26360 4 lastentrance_dmap = currdmap;
26361 4 lastentrance = homescr;
26362 4 }
26363 2978 }
26364 3365 }
26365 3365 }
26366
26367
2/2
✓ Branch 0 taken 6403573 times.
✓ Branch 1 taken 2579 times.
6406152 if(y>160)
26368 {
26369 2579 bool doit=true;
26370 2579 y=160;
26371
26372
5/6
✓ Branch 0 taken 2555 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 2555 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 2556 times.
2579 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26373 23 doit = false;
26374
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2578 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2579 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26375 doit = false;
26376
26377
1/2
✓ Branch 0 taken 2579 times.
✗ Branch 1 not taken.
2579 if(nextcombo_wf(down))
26378 doit=false;
26379
26380
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2579 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2579 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
26381 {
26382 if(nextcombo_solid(down))
26383 doit=false;
26384 }
26385
26386
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 2556 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
2579 if(doit || action==inwind)
26387 {
26388
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 2297 times.
2556 if(currscr>=128)
26389 {
26390
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 if(specialcave >= GUYCAVE)
26391 259 exitcave();
26392 else stepout();
26393 259 }
26394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2297 times.
2297 else if(action==inwind)
26395 {
26396 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26397 {
26398 action=none; FFCore.setHeroAction(none);
26399 restart_level();
26400 }
26401 else
26402 {
26403 dowarp(2,down);
26404 }
26405 }
26406
3/6
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 2122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2297 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26407 {
26408 175 sdir=down;
26409 175 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
26410 175 }
26411
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2117 times.
2122 else if(!edge_of_dmap(down))
26412 {
26413 2117 scrolling_map = currmap;
26414 2117 scrollscr(down);
26415
26416
1/2
✓ Branch 0 taken 2117 times.
✗ Branch 1 not taken.
2117 if(tmpscr->flags4&fAUTOSAVE)
26417 {
26418 save_game(true,0);
26419 }
26420
26421
2/2
✓ Branch 0 taken 2115 times.
✓ Branch 1 taken 2 times.
2117 if(tmpscr->flags6&fCONTINUEHERE)
26422 {
26423 2 lastentrance_dmap = currdmap;
26424 2 lastentrance = homescr;
26425 2 }
26426 2117 }
26427 2556 }
26428 2579 }
26429
26430
2/2
✓ Branch 0 taken 6403501 times.
✓ Branch 1 taken 2651 times.
6406152 if(x<0)
26431 {
26432 2651 bool doit=true;
26433 2651 x=0;
26434
26435
4/6
✓ Branch 0 taken 2650 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2650 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2649 times.
2651 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26436 doit = false;
26437
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2625 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
2649 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26438 doit = false;
26439
26440
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 if(nextcombo_wf(left))
26441 doit=false;
26442
26443
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2649 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2649 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
26444 {
26445 if(nextcombo_solid(left))
26446 doit=false;
26447 }
26448
26449
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2649 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
2649 if(doit || action==inwind)
26450 {
26451
1/2
✓ Branch 0 taken 2650 times.
✗ Branch 1 not taken.
2650 if(currscr>=128)
26452 {
26453 if(specialcave >= GUYCAVE)
26454 exitcave();
26455 else stepout();
26456 }
26457
26458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2650 times.
2650 if(action==inwind)
26459 {
26460 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26461 {
26462 action=none; FFCore.setHeroAction(none);
26463 restart_level();
26464 }
26465 else
26466 {
26467 dowarp(2,left);
26468 }
26469 }
26470
3/6
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2557 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2650 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26471 {
26472 93 sdir=left;
26473 93 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
26474 93 }
26475
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 2445 times.
2557 else if(!edge_of_dmap(left))
26476 {
26477 2445 scrolling_map = currmap;
26478 2445 scrollscr(left);
26479
26480
1/2
✓ Branch 0 taken 2445 times.
✗ Branch 1 not taken.
2445 if(tmpscr->flags4&fAUTOSAVE)
26481 {
26482 save_game(true,0);
26483 }
26484
26485
2/2
✓ Branch 0 taken 2437 times.
✓ Branch 1 taken 8 times.
2445 if(tmpscr->flags6&fCONTINUEHERE)
26486 {
26487 8 lastentrance_dmap = currdmap;
26488 8 lastentrance = homescr;
26489 8 }
26490 2445 }
26491 2650 }
26492 2651 }
26493
26494
2/2
✓ Branch 0 taken 6403104 times.
✓ Branch 1 taken 3046 times.
6406150 if(x>240)
26495 {
26496 3046 bool doit=true;
26497 3046 x=240;
26498
26499
5/6
✓ Branch 0 taken 3033 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 3033 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 3033 times.
3046 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26500 13 doit = false;
26501
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3046 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3046 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26502 doit = false;
26503
26504
1/2
✓ Branch 0 taken 3046 times.
✗ Branch 1 not taken.
3046 if(nextcombo_wf(right))
26505 doit=false;
26506
26507
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3046 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3046 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
26508 {
26509 if(nextcombo_solid(right))
26510 doit=false;
26511 }
26512
26513
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3033 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
3046 if(doit || action==inwind)
26514 {
26515
1/2
✓ Branch 0 taken 3033 times.
✗ Branch 1 not taken.
3033 if(currscr>=128)
26516 {
26517 if(specialcave >= GUYCAVE)
26518 exitcave();
26519 else stepout();
26520 }
26521
26522
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 2966 times.
3033 if(action==inwind)
26523 {
26524
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 66 times.
67 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26525 {
26526 1 action=none; FFCore.setHeroAction(none);
26527 1 restart_level();
26528 1 }
26529 else
26530 {
26531 66 dowarp(2,right);
26532 }
26533 67 }
26534
3/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 2866 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2966 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26535 {
26536 100 sdir=right;
26537 100 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
26538 100 }
26539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2866 times.
2866 else if(!edge_of_dmap(right))
26540 {
26541 2866 scrolling_map = currmap;
26542 2866 scrollscr(right);
26543
26544
1/2
✓ Branch 0 taken 2866 times.
✗ Branch 1 not taken.
2866 if(tmpscr->flags4&fAUTOSAVE)
26545 {
26546 save_game(true,0);
26547 }
26548
26549
2/2
✓ Branch 0 taken 2856 times.
✓ Branch 1 taken 10 times.
2866 if(tmpscr->flags6&fCONTINUEHERE)
26550 {
26551 10 lastentrance_dmap = currdmap;
26552 10 lastentrance = homescr;
26553 10 }
26554 2866 }
26555 3033 }
26556 3046 }
26557 6406150 }
26558
26559 // assumes current direction is in lastdir[3]
26560 // compares directions with scr->path and scr->exitdir
26561 31230 bool HeroClass::checkmaze(mapscr *scr, bool sound)
26562 {
26563
2/2
✓ Branch 0 taken 30879 times.
✓ Branch 1 taken 351 times.
31230 if(!(scr->flags&fMAZE))
26564 30879 return true;
26565
26566
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 305 times.
351 if(lastdir[3]==scr->exitdir)
26567 46 return true;
26568
26569
2/2
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 44 times.
523 for(int32_t i=0; i<4; i++)
26570
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 261 times.
479 if(lastdir[i]!=scr->path[i])
26571 261 return false;
26572
26573
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 22 times.
44 if(sound)
26574 22 sfx(scr->secretsfx);
26575
26576 44 return true;
26577 31230 }
26578
26579 20823 bool HeroClass::edge_of_dmap(int32_t side)
26580 {
26581
2/2
✓ Branch 0 taken 20670 times.
✓ Branch 1 taken 153 times.
20823 if(checkmaze(tmpscr,false)==false)
26582 153 return false;
26583
26584 // needs fixin'
26585 // should check dmap style
26586
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5863 times.
✓ Branch 2 taken 4191 times.
✓ Branch 3 taken 4945 times.
✓ Branch 4 taken 5671 times.
20670 switch(side)
26587 {
26588 case up:
26589 5863 return currscr<16;
26590
26591 case down:
26592 4191 return currscr>=112;
26593
26594 case left:
26595
2/2
✓ Branch 0 taken 4833 times.
✓ Branch 1 taken 112 times.
4945 if((currscr&15)==0)
26596 112 return true;
26597
26598
2/2
✓ Branch 0 taken 2574 times.
✓ Branch 1 taken 2259 times.
4833 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
26599 // if(dlevel)
26600 2574 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
26601
26602 2259 break;
26603
26604 case right:
26605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5671 times.
5671 if((currscr&15)==15)
26606 return true;
26607
26608
2/2
✓ Branch 0 taken 3205 times.
✓ Branch 1 taken 2466 times.
5671 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
26609 // if(dlevel)
26610 3205 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
26611
26612 2466 break;
26613 }
26614
26615 4725 return false;
26616 20823 }
26617
26618 196 bool HeroClass::lookaheadraftflag(int32_t d2)
26619 {
26620 // Helper for scrollscr that gets next combo on next screen.
26621 // Can use destscr for scrolling warps,
26622 // but assumes currmap is correct.
26623
26624 196 int32_t cx = x;
26625 196 int32_t cy = y + 8;
26626
26627 196 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26628 196 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26629 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26630 //Applying this here, too. -Z
26631
26632
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 57 times.
196 switch(d2)
26633 {
26634 case up:
26635 51 cy=160;
26636 51 break;
26637
26638 case down:
26639 41 cy=0;
26640 41 break;
26641
26642 case left:
26643 47 cx=240;
26644 47 break;
26645
26646 case right:
26647 57 cx=0;
26648 57 break;
26649 }
26650
26651 196 int32_t combo = (cy&0xF0)+(cx>>4);
26652
26653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 if(combo>175)
26654 return 0;
26655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
26656
26657 196 }
26658 10721 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
26659 {
26660 // Can use destscr for scrolling warps,
26661 // but assumes currmap is correct.
26662
26663 10721 int32_t cx = vbound(x,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
26664 10721 int32_t cy = vbound(y + 8,0,160);
26665 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26666 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26667 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26668
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3024 times.
✓ Branch 2 taken 2171 times.
✓ Branch 3 taken 2512 times.
✓ Branch 4 taken 3014 times.
10721 switch(d2)
26669 {
26670 case up:
26671 3024 cy=160;
26672 3024 break;
26673
26674 case down:
26675 2171 cy=0;
26676 2171 break;
26677
26678 case left:
26679 2512 cx=240;
26680 2512 break;
26681
26682 case right:
26683 3014 cx=0;
26684 3014 break;
26685 }
26686
26687 10721 int32_t combo = (cy&0xF0)+(cx>>4);
26688
26689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10721 times.
10721 if(combo>175)
26690 return 0;
26691
26692 10721 return tmpscr[0].data[combo]; // entire combo code
26693 10721 }
26694
26695 10721 int32_t HeroClass::lookaheadflag(int32_t d2)
26696 {
26697 // Helper for scrollscr that gets next combo on next screen.
26698 // Can use destscr for scrolling warps,
26699 // but assumes currmap is correct.
26700
26701 10721 int32_t cx = vbound(x,0,240);
26702 10721 int32_t cy = vbound(y + 8,0,160);
26703
26704 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26705 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26706 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26707 //Applying this here, too. -Z
26708
26709
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3024 times.
✓ Branch 2 taken 2171 times.
✓ Branch 3 taken 2512 times.
✓ Branch 4 taken 3014 times.
10721 switch(d2)
26710 {
26711 case up:
26712 3024 cy=160;
26713 3024 break;
26714
26715 case down:
26716 2171 cy=0;
26717 2171 break;
26718
26719 case left:
26720 2512 cx=240;
26721 2512 break;
26722
26723 case right:
26724 3014 cx=0;
26725 3014 break;
26726 }
26727
26728 10721 int32_t combo = (cy&0xF0)+(cx>>4);
26729
26730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10721 times.
10721 if(combo>175)
26731 return 0;
26732
26733
2/2
✓ Branch 0 taken 10442 times.
✓ Branch 1 taken 279 times.
10721 if(!tmpscr[0].sflag[combo])
26734 {
26735 10442 return combobuf[tmpscr[0].data[combo]].flag; // flag
26736 }
26737
26738 279 return tmpscr[0].sflag[combo]; // flag
26739 10721 }
26740
26741 1394985 void HeroClass::run_scrolling_script_int(bool waitdraw)
26742 {
26743
2/2
✓ Branch 0 taken 697383 times.
✓ Branch 1 taken 697602 times.
1394985 if(waitdraw)
26744 {
26745
3/4
✓ Branch 0 taken 697383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 601005 times.
✓ Branch 3 taken 96378 times.
697383 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
26746 {
26747 96378 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
26748 96378 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
26749 96378 }
26750 697383 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
26751
4/6
✓ Branch 0 taken 697383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 693976 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3407 times.
697383 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26752 {
26753 3407 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
26754 3407 FFCore.waitdraw(ScriptType::Player) = false;
26755 3407 }
26756 697383 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
26757
4/6
✓ Branch 0 taken 697383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 697349 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
697383 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26758 {
26759 34 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
26760 34 FFCore.waitdraw(ScriptType::DMap) = false;
26761 34 }
26762 697383 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
26763
2/6
✓ Branch 0 taken 697383 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 697383 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
697383 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::PassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26764 {
26765 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
26766 FFCore.waitdraw(ScriptType::PassiveSubscreen) = false;
26767 }
26768 697383 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
26769
4/10
✓ Branch 0 taken 697383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 697366 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
697383 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen) && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26770 {
26771 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
26772 FFCore.waitdraw(ScriptType::Screen) = 0;
26773 }
26774 697383 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
26775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697383 times.
697383 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
26776 {
26777 697383 FFCore.itemScriptEngineOnWaitdraw();
26778 697383 }
26779 697383 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
26780 697383 }
26781 else
26782 {
26783
4/8
✓ Branch 0 taken 697602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 697584 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
697602 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26784 {
26785 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
26786 }
26787 697602 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
26788
3/4
✓ Branch 0 taken 697602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148183 times.
✓ Branch 3 taken 549419 times.
697602 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.doscript(ScriptType::Global, GLOBAL_SCRIPT_GAME))
26789 {
26790 148183 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
26791 148183 }
26792 697602 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
26793
5/6
✓ Branch 0 taken 697602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 689963 times.
✓ Branch 3 taken 7639 times.
✓ Branch 4 taken 686556 times.
✓ Branch 5 taken 3407 times.
697602 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.doscript(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
26794 {
26795 3407 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
26796 3407 }
26797 697602 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
26798
4/6
✓ Branch 0 taken 697602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 697602 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 686556 times.
✓ Branch 5 taken 11046 times.
697602 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26799 {
26800 11046 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
26801 11046 }
26802 697602 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
26803
4/6
✓ Branch 0 taken 697602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 697602 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 686556 times.
✓ Branch 5 taken 11046 times.
697602 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::PassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26804 {
26805 11046 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
26806 11046 }
26807 697602 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
26808 697602 bool old = get_bit(quest_rules, qr_OLD_ITEMDATA_SCRIPT_TIMING);
26809
3/4
✓ Branch 0 taken 697602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4864 times.
✓ Branch 3 taken 692738 times.
697602 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
26810 692738 FFCore.itemScriptEngine();
26811 697602 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
26812
3/4
✓ Branch 0 taken 697602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692738 times.
✓ Branch 3 taken 4864 times.
697602 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
26813 4864 FFCore.itemScriptEngine();
26814 }
26815 1394985 }
26816 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
26817 1394985 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
26818 {
26819 // For rafting (and possibly other esoteric things)
26820 // Hero's action should remain unchanged while scrolling,
26821 // but for the sake of scripts, here's an eye-watering kludge.
26822 1394985 actiontype lastaction = action;
26823 1394985 action=scrolling; FFCore.setHeroAction(scrolling);
26824
2/2
✓ Branch 0 taken 697383 times.
✓ Branch 1 taken 697602 times.
1394985 if(waitdraw)
26825 {
26826 697383 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
26827 697383 }
26828 else
26829 {
26830 697602 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
26831 }
26832 1394985 zfix storex = x, storey = y;
26833
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 348188 times.
✓ Branch 2 taken 237048 times.
✓ Branch 3 taken 366808 times.
✓ Branch 4 taken 442941 times.
1394985 switch(scrolldir)
26834 {
26835 case up:
26836
2/2
✓ Branch 0 taken 290046 times.
✓ Branch 1 taken 58142 times.
348188 if(y < 160) y = 176;
26837
4/4
✓ Branch 0 taken 49333 times.
✓ Branch 1 taken 8809 times.
✓ Branch 2 taken 18879 times.
✓ Branch 3 taken 30454 times.
58142 else if(cx > 0 && !end_frames) y = sy + 156;
26838 27688 else y = 160;
26839
26840 348188 break;
26841
26842 case down:
26843
2/2
✓ Branch 0 taken 196575 times.
✓ Branch 1 taken 40473 times.
237048 if(y > 0) y = -16;
26844
4/4
✓ Branch 0 taken 34075 times.
✓ Branch 1 taken 6398 times.
✓ Branch 2 taken 14112 times.
✓ Branch 3 taken 19963 times.
40473 else if(cx > 0 && !end_frames) y = sy - 172;
26845 20510 else y = 0;
26846
26847 237048 break;
26848
26849 case left:
26850
2/2
✓ Branch 0 taken 337030 times.
✓ Branch 1 taken 29778 times.
366808 if(x < 240) x = 256;
26851
2/2
✓ Branch 0 taken 24704 times.
✓ Branch 1 taken 5074 times.
29778 else if(cx > 0) x = sx + 236;
26852 5074 else x = 240;
26853
26854 366808 break;
26855
26856 case right:
26857
2/2
✓ Branch 0 taken 407037 times.
✓ Branch 1 taken 35904 times.
442941 if(x > 0) x = -16;
26858
2/2
✓ Branch 0 taken 29812 times.
✓ Branch 1 taken 6092 times.
35904 else if(cx > 0) x = sx - 252;
26859 6092 else x = 0;
26860
26861 442941 break;
26862 }
26863 1394985 run_scrolling_script_int(waitdraw);
26864
26865 1394985 x = storex, y = storey;
26866
26867 1394985 action=lastaction; FFCore.setHeroAction(lastaction);
26868 1394985 }
26869
26870 //Has solving the maze enabled a side warp?
26871 //Only used just before scrolling screens
26872 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
26873 // return true to abort the topmost scrollscr() call. -L
26874 10722 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
26875 {
26876
2/2
✓ Branch 0 taken 32166 times.
✓ Branch 1 taken 10722 times.
42888 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
26877
26878
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 10569 times.
10722 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
26879
26880
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10722 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10722 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
26881 {
26882 switch(scrolldir)
26883 {
26884 case up:
26885 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
26886 {
26887 lastdir[3] = 0xFF;
26888 sdir=up;
26889 dowarp(1,(tmpscr->sidewarpindex)&3);
26890 return true;
26891 }
26892
26893 break;
26894
26895 case down:
26896 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
26897 {
26898 lastdir[3] = 0xFF;
26899 sdir=down;
26900 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
26901 return true;
26902 }
26903
26904 break;
26905
26906 case left:
26907 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
26908 {
26909 lastdir[3] = 0xFF;
26910 sdir=left;
26911 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
26912 return true;
26913 }
26914
26915 break;
26916
26917 case right:
26918 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
26919 {
26920 lastdir[3] = 0xFF;
26921 sdir=right;
26922 dowarp(1,(tmpscr->sidewarpindex)&3);
26923 return true;
26924 }
26925
26926 break;
26927 }
26928 }
26929
26930 10722 return false;
26931 10722 }
26932
26933 10722 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
26934 {
26935 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
26936
2/2
✓ Branch 0 taken 636 times.
✓ Branch 1 taken 10086 times.
10722 if(get_bit(quest_rules, qr_VERYFASTSCROLLING))
26937 636 return 16;
26938
26939
2/2
✓ Branch 0 taken 9057 times.
✓ Branch 1 taken 1029 times.
10086 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0)
26940 {
26941
2/2
✓ Branch 0 taken 5099 times.
✓ Branch 1 taken 3958 times.
9057 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
26942 }
26943 else
26944 {
26945
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
26946 {
26947 482 return 8;
26948 }
26949 else
26950 {
26951
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 332 times.
547 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
26952 }
26953 }
26954 10722 }
26955
26956 10722 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
26957 {
26958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10722 times.
10722 if(get_bit(quest_rules, qr_NOSCROLL))
26959 return 0;
26960
26961
4/4
✓ Branch 0 taken 10086 times.
✓ Branch 1 taken 636 times.
✓ Branch 2 taken 9057 times.
✓ Branch 3 taken 1029 times.
10722 if( (get_bit(quest_rules, qr_VERYFASTSCROLLING) != 0) ||
26962 10086 (get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0) )
26963 {
26964 9693 return 1;
26965 }
26966 else
26967 {
26968
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
26969 {
26970
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 234 times.
482 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 4 : 2;
26971 }
26972 else
26973 {
26974 547 return 1;
26975 }
26976 }
26977 10722 }
26978
26979 5933 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
26980 {
26981 5933 int32_t lampid = current_item_id(itype_lantern);
26982
1/2
✓ Branch 0 taken 5933 times.
✗ Branch 1 not taken.
5933 if(lampid < 0) return;
26983 static bool lamp_paid = false;
26984
2/4
✓ Branch 0 taken 5933 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5933 times.
✗ Branch 3 not taken.
5933 if(!(checkbunny(lampid) && checkmagiccost(lampid,lamp_paid)))
26985 {
26986 lamp_paid = false;
26987 return;
26988 }
26989 5933 lamp_paid = true;
26990 5933 paymagiccost(lampid,false,true);
26991 5933 int32_t hx1 = x.getInt() - x1 + 8;
26992 5933 int32_t hy1 = y.getInt() - y1 + 8;
26993 5933 int32_t hx2 = x.getInt() - x2 + 8;
26994 5933 int32_t hy2 = y.getInt() - y2 + 8;
26995
26996 5933 itemdata& lamp = itemsbuf[lampid];
26997
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5545 times.
✓ Branch 2 taken 388 times.
5933 switch(lamp.misc1) //Shape
26998 {
26999 case 0: //Circle
27000 5545 doDarkroomCircle(hx1, hy1, lamp.misc2, darkscr_bmp_curscr);
27001 5545 doDarkroomCircle(hx2, hy2, lamp.misc2, darkscr_bmp_scrollscr);
27002 5545 break;
27003 case 1: //Lamp Cone
27004 388 doDarkroomCone(hx1, hy1, lamp.misc2, dir, darkscr_bmp_curscr);
27005 388 doDarkroomCone(hx2, hy2, lamp.misc2, dir, darkscr_bmp_scrollscr);
27006 388 break;
27007 }
27008 5933 }
27009
27010 10723 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
27011 {
27012
4/4
✓ Branch 0 taken 10722 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 10723 times.
10723 if(action==freeze||action==sideswimfreeze)
27013 {
27014 2 return;
27015 }
27016
27017 10723 bool overlay = false;
27018
27019
3/4
✓ Branch 0 taken 10722 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10722 times.
10723 if(scrolldir >= 0 && scrolldir <= 3)
27020 {
27021 10722 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
27022 10722 }
27023
27024
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 10407 times.
10723 if(destdmap == -1)
27025 {
27026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10407 times.
10407 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[currdmap].map].tileWidth
27027
1/2
✓ Branch 0 taken 10407 times.
✗ Branch 1 not taken.
10407 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[currdmap].map].tileHeight)
27028 return;
27029 10407 }
27030 else
27031 {
27032
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 316 times.
316 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[destdmap].map].tileWidth
27033
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 1 times.
316 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[destdmap].map].tileHeight)
27034 2 return;
27035 }
27036
27037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10723 times.
10723 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
27038 return;
27039
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10723 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10723 bool isForceFaceUp = getOnSideviewLadder() && canSideviewLadder() &&
27040 !(jumping<0 || fall!=0 || fakefall!=0) && get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP);
27041
1/2
✓ Branch 0 taken 10723 times.
✗ Branch 1 not taken.
10723 if(isForceFaceUp) dir = up;
27042 10723 kill_enemy_sfx();
27043 10723 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27044 10723 screenscrolling = true;
27045 10723 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
27046
5/5
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3025 times.
✓ Branch 2 taken 2171 times.
✓ Branch 3 taken 2512 times.
✓ Branch 4 taken 3014 times.
10723 switch(scrolldir)
27047 {
27048 case up:
27049 3025 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27050 3025 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
27051 3025 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27052 3025 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27053 3025 break;
27054 case down:
27055 2171 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27056 2171 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
27057 2171 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27058 2171 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27059 2171 break;
27060 case left:
27061 2512 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
27062 2512 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27063 2512 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27064 2512 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27065 2512 break;
27066 case right:
27067 3014 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
27068 3014 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27069 3014 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27070 3014 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27071 3014 break;
27072 }
27073 10723 FFCore.clear_combo_scripts();
27074 10723 tmpscr[1] = tmpscr[0];
27075
27076 10723 const int32_t _mapsSize = ZCMaps[currmap].tileWidth * ZCMaps[currmap].tileHeight;
27077
27078
2/2
✓ Branch 0 taken 64332 times.
✓ Branch 1 taken 10723 times.
75055 for(int32_t i = 0; i < 6; i++)
27079 {
27080 64332 tmpscr3[i] = tmpscr2[i];
27081 64332 }
27082
27083 10723 conveyclk = 2;
27084
27085 10723 mapscr *newscr = &tmpscr[0];
27086 10723 mapscr *oldscr = &tmpscr[1];
27087
27088 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
27089 10723 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
27090 10723 int32_t cx = 0;
27091 10723 int32_t step = get_scroll_step(scrolldir);
27092 10723 int32_t delay = get_scroll_delay(scrolldir);
27093 10723 bool end_frames = false;
27094
27095 10723 int32_t scx = get_bit(quest_rules,qr_FASTDNGN) ? 30 : 0;
27096
2/2
✓ Branch 0 taken 10087 times.
✓ Branch 1 taken 636 times.
10723 if(get_bit(quest_rules, qr_VERYFASTSCROLLING)) //just a minor adjustment.
27097 636 scx = 32; //for sideview very fast screolling.
27098
27099
27100 10723 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
27101 10723 actiontype lastaction = action;
27102 10723 ALLOFF(false, false);
27103 // for now, restore Hero's previous action
27104
2/2
✓ Branch 0 taken 10504 times.
✓ Branch 1 taken 219 times.
10723 if(!get_bit(quest_rules, qr_SCROLLING_KILLS_CHARGE))
27105 10723 attackclk = lastattackclk; spins = lastspins; charging = lastcharging; tapping = lasttapping;
27106 10723 action=lastaction; FFCore.setHeroAction(lastaction);
27107
27108 10723 lstep = (lstep + 6) % 12;
27109 10723 cx = scx;
27110 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
27111
4/4
✓ Branch 0 taken 10722 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8627 times.
✓ Branch 3 taken 2095 times.
10723 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
27112 {
27113 2095 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
27114 2095 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
27115 2095 }
27116 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
27117
5/6
✓ Branch 0 taken 10722 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 194 times.
✓ Branch 3 taken 10528 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 194 times.
10723 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27118 {
27119 194 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
27120 194 FFCore.waitdraw(ScriptType::Player) = false;
27121 194 }
27122 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
27123
5/6
✓ Branch 0 taken 10722 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 10720 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
10723 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27124 {
27125 2 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
27126 2 FFCore.waitdraw(ScriptType::DMap) = false;
27127 2 }
27128 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
27129
3/6
✓ Branch 0 taken 10722 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10722 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10723 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::PassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27130 {
27131 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
27132 FFCore.waitdraw(ScriptType::PassiveSubscreen) = false;
27133 }
27134 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
27135
3/8
✓ Branch 0 taken 10722 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10722 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10723 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27136 {
27137 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
27138 FFCore.waitdraw(ScriptType::Screen) = 0;
27139 }
27140 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
27141
27142 10723 word c = tmpscr->numFFC();
27143
2/2
✓ Branch 0 taken 337152 times.
✓ Branch 1 taken 10723 times.
347875 for ( word q = 0; q < c; ++q )
27144 {
27145
1/2
✓ Branch 0 taken 337152 times.
✗ Branch 1 not taken.
337152 if (FFCore.waitdraw(ScriptType::FFC, q))
27146 {
27147 if(tmpscr->ffcs[q].script != 0)
27148 {
27149 ZScriptVersion::RunScript(ScriptType::FFC, tmpscr->ffcs[q].script, q);
27150 FFCore.waitdraw(ScriptType::FFC, q) = false;
27151 }
27152 }
27153 337152 }
27154 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
27155 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
27156 //Waitdraw for item scripts.
27157 10723 FFCore.itemScriptEngineOnWaitdraw();
27158 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
27159 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
27160
27161 //Sprite scripts on Waitdraw
27162 10723 FFCore.eweaponScriptEngineOnWaitdraw();
27163 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
27164 10723 FFCore.itemSpriteScriptEngineOnWaitdraw();
27165 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
27166
27167 //This is no longer a do-while, as the first iteration is now slightly different. -Em
27168 10723 draw_screen(tmpscr,true,true);
27169
27170
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10722 times.
10723 if(cx == scx)
27171 10722 rehydratelake(false);
27172
27173 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27174 10723 advanceframe(true);
27175
27176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10723 times.
10723 if(Quit)
27177 {
27178 screenscrolling = false;
27179 return;
27180 }
27181
27182 10723 ++cx;
27183
2/2
✓ Branch 0 taken 109416 times.
✓ Branch 1 taken 10723 times.
120139 while(cx < 32)
27184 {
27185
1/2
✓ Branch 0 taken 109416 times.
✗ Branch 1 not taken.
109416 if(isForceFaceUp) dir = up;
27186
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 109398 times.
109416 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
27187 {
27188 18 script_drawing_commands.Clear();
27189 18 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27190 18 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
27191 18 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
27192 18 }
27193 109398 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27194 109416 draw_screen(tmpscr,true,true);
27195
27196
1/2
✓ Branch 0 taken 109416 times.
✗ Branch 1 not taken.
109416 if(cx == scx)
27197 rehydratelake(false);
27198
27199 109416 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27200 109416 advanceframe(true);
27201
27202
1/2
✓ Branch 0 taken 109416 times.
✗ Branch 1 not taken.
109416 if(Quit)
27203 {
27204 screenscrolling = false;
27205 return;
27206 }
27207
27208 109416 ++cx;
27209 }
27210 10723 script_drawing_commands.Clear();
27211 10723 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27212
27213
27214 //clear Hero's last hits
27215 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
27216
27217
4/4
✓ Branch 0 taken 5306 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 4420 times.
10723 switch(DMaps[currdmap].type&dmfTYPE)
27218 {
27219 case dmDNGN:
27220
1/2
✓ Branch 0 taken 4420 times.
✗ Branch 1 not taken.
4420 if(!get_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING))
27221 {
27222 markBmap(scrolldir);
27223 }
27224 4420 break;
27225 case dmOVERW: case dmBSOVERW:
27226
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 5240 times.
5306 if(get_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING))
27227 5240 break;
27228 [[fallthrough]];
27229 case dmCAVE:
27230 1062 markBmap(scrolldir);
27231 1062 break;
27232 }
27233
27234
1/2
✓ Branch 0 taken 10723 times.
✗ Branch 1 not taken.
10723 if(fixed_door)
27235 {
27236 unsetmapflag(mSECRET);
27237 fixed_door = false;
27238 }
27239 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
27240 10723 scrolling_scr = currscr;
27241
27242
5/5
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3025 times.
✓ Branch 2 taken 2171 times.
✓ Branch 3 taken 2512 times.
✓ Branch 4 taken 3014 times.
10723 switch(scrolldir)
27243 {
27244 case up:
27245 {
27246
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 2979 times.
3025 if(destscr != -1)
27247 46 currscr = destscr;
27248
3/4
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2934 times.
2979 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27249 2934 currscr -= 16;
27250
27251 3025 loadscr(0,destdmap,currscr,scrolldir,overlay);
27252 3025 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
27253 3025 putscr(scrollbuf,0,0,newscr);
27254 3025 putscrdoors(scrollbuf,0,0,newscr);
27255 3025 sy=176;
27256
27257
2/2
✓ Branch 0 taken 2698 times.
✓ Branch 1 taken 327 times.
3025 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
27258 327 sy+=3;
27259
27260 3025 cx=176/step;
27261 3025 FFCore.clear_combo_scripts();
27262 }
27263 3025 break;
27264
27265 case down:
27266 {
27267
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 2117 times.
2171 if(destscr != -1)
27268 54 currscr = destscr;
27269
3/4
✓ Branch 0 taken 2099 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2099 times.
2117 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27270 2099 currscr += 16;
27271
27272 2171 loadscr(0,destdmap,currscr,scrolldir,overlay);
27273 2171 putscr(scrollbuf,0,176,newscr);
27274 2171 putscrdoors(scrollbuf,0,176,newscr);
27275 2171 sy = 0;
27276
27277
2/2
✓ Branch 0 taken 2016 times.
✓ Branch 1 taken 155 times.
2171 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
27278 155 sy+=3;
27279
27280 2171 cx = 176 / step;
27281 2171 FFCore.clear_combo_scripts();
27282 }
27283 2171 break;
27284
27285 case left:
27286 {
27287
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 2445 times.
2512 if(destscr!=-1)
27288 67 currscr = destscr;
27289
3/4
✓ Branch 0 taken 2427 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2427 times.
2445 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27290 2427 --currscr;
27291
27292 2512 loadscr(0,destdmap,currscr,scrolldir,overlay);
27293 2512 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
27294 2512 putscr(scrollbuf,0,0,newscr);
27295 2512 putscrdoors(scrollbuf,0,0,newscr);
27296 2512 sx = 256;
27297 2512 cx = 256 / step;
27298 2512 FFCore.clear_combo_scripts();
27299 }
27300 2512 break;
27301
27302 case right:
27303 {
27304
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 2866 times.
3014 if(destscr != -1)
27305 148 currscr = destscr;
27306
3/4
✓ Branch 0 taken 2839 times.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2839 times.
2866 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27307 2839 ++currscr;
27308
27309 3014 loadscr(0,destdmap,currscr,scrolldir,overlay);
27310 3014 putscr(scrollbuf,256,0,newscr);
27311 3014 putscrdoors(scrollbuf,256,0,tmpscr);
27312 3014 sx = 0;
27313 3014 cx = 256 / step;
27314 3014 FFCore.clear_combo_scripts();
27315 }
27316 3014 break;
27317 }
27318
27319 // change Hero's state if entering water
27320 10723 int32_t ahead = lookahead(scrolldir);
27321 10723 int32_t aheadflag = lookaheadflag(scrolldir);
27322 10723 int32_t lookaheadx = vbound(x+8,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
27323 10723 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0,160);
27324 10723 int32_t wateraheadx1 = vbound(x+4,0,240);
27325 10723 int32_t wateraheadx2 = vbound(x+11,0,240);;
27326 10723 int32_t wateraheady1 = vbound(y+9,0,160);
27327 10723 int32_t wateraheady2 = vbound(y+15,0,160);
27328 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27329 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27330 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
27331
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3024 times.
✓ Branch 2 taken 2171 times.
✓ Branch 3 taken 2512 times.
✓ Branch 4 taken 3014 times.
10723 switch(scrolldir)
27332 {
27333 case up:
27334 3024 lookaheady=160;
27335 3024 wateraheady1=160;
27336 3024 wateraheady2=160;
27337 3024 break;
27338
27339 case down:
27340 2171 lookaheady=0;
27341 2171 wateraheady1=0;
27342 2171 wateraheady2=0;
27343 2171 break;
27344
27345 case left:
27346 2512 lookaheadx=240;
27347 2512 wateraheadx1=240;
27348 2512 wateraheadx2=240;
27349 2512 break;
27350
27351 case right:
27352 3014 lookaheadx=0;
27353 3014 wateraheadx1=0;
27354 3014 wateraheadx2=0;
27355 3014 break;
27356 }
27357
27358 10721 bool nowinwater = false;
27359
27360
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 10655 times.
10721 if(lastaction != inwind)
27361 {
27362
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 10459 times.
10655 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
27363 {
27364
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 189 times.
196 if (lookaheadraftflag(scrolldir))
27365 {
27366 189 action=rafting; FFCore.setHeroAction(rafting);
27367 189 raftclk=0;
27368 189 }
27369 196 }
27370
5/6
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 10282 times.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 156 times.
10459 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
27371 {
27372
9/16
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10 times.
✗ Branch 15 not taken.
156 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
27373 {
27374 146 SetSwim();
27375 146 hopclk = 0xFF;
27376 146 nowinwater = true;
27377 146 }
27378 else
27379 {
27380 10 action=hopping; FFCore.setHeroAction(hopping);
27381 10 hopclk = 2;
27382 10 nowinwater = true;
27383 }
27384 156 }
27385
3/4
✓ Branch 0 taken 10290 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10303 times.
10303 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
27386 {
27387 action = lastaction; FFCore.setHeroAction(lastaction);
27388 }
27389 else
27390 {
27391 10303 action=none; FFCore.setHeroAction(none);
27392 }
27393 10655 }
27394
27395
1/2
✓ Branch 0 taken 10721 times.
✗ Branch 1 not taken.
10721 isForceFaceUp = isForceFaceUp && canSideviewLadderRemote(lookaheadx,lookaheady);
27396
27397 // The naturaldark state can be read/set by an FFC script before
27398 // fade() or lighting() is called.
27399 10721 naturaldark = ((TheMaps[currmap*MAPSCRS+currscr].flags & fDARK) != 0);
27400
27401
2/2
✓ Branch 0 taken 10489 times.
✓ Branch 1 taken 232 times.
10721 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
27402
27403
2/2
✓ Branch 0 taken 10478 times.
✓ Branch 1 taken 243 times.
10721 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
27404 //Preloaded ffc scripts
27405 10721 homescr=currscr;
27406 10721 auto olddmap = currdmap;
27407
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 10406 times.
10721 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
27408
27409 10721 currdmap = newdmap;
27410 10721 ffscript_engine(true);
27411 10721 currdmap = olddmap;
27412
27413 // There are two occasions when scrolling must be darkened:
27414 // 1) When scrolling into a dark room.
27415 // 2) When scrolling between DMaps of different colours.
27416
4/4
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 10406 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 125 times.
10721 if(destdmap != -1 && DMaps[destdmap].color != currcset)
27417 {
27418
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
27419 125 darkroom = true;
27420 125 }
27421
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 10419 times.
10596 else if(!darkroom)
27422 10419 lighting(false, false); // NES behaviour: fade to dark before scrolling
27423
27424
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 10525 times.
10721 if(action != rafting) // Is this supposed to be here?!
27425
27426 10525 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
27427
27428 10721 cx *= delay; //so we can have drawing re-done every frame,
27429 //previously it was for(0 to delay) advanceframes at end of loop
27430 10721 int32_t no_move = 0;
27431
27432 10721 currdmap = newdmap;
27433
4/4
✓ Branch 0 taken 10721 times.
✓ Branch 1 taken 697365 times.
✓ Branch 2 taken 697365 times.
✓ Branch 3 taken 10721 times.
708086 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
27434 {
27435
3/4
✓ Branch 0 taken 697365 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 575916 times.
✓ Branch 3 taken 121449 times.
697365 if (replay_is_active() && replay_get_version() < 3)
27436 {
27437 121449 replay_poll();
27438 121449 }
27439
1/2
✓ Branch 0 taken 697365 times.
✗ Branch 1 not taken.
697365 if(Quit)
27440 {
27441 screenscrolling = false;
27442 return;
27443 }
27444
27445
27446 697365 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
27447
27448
2/2
✓ Branch 0 taken 643544 times.
✓ Branch 1 taken 53821 times.
697365 if(no_move > 0)
27449 53821 no_move--;
27450
27451 //Don't want to move things on the first or last iteration, or between delays
27452
6/6
✓ Branch 0 taken 686644 times.
✓ Branch 1 taken 10721 times.
✓ Branch 2 taken 671210 times.
✓ Branch 3 taken 15434 times.
✓ Branch 4 taken 23129 times.
✓ Branch 5 taken 648081 times.
697365 if(i == 0 || cx == 0 || cx % delay != 0)
27453 49284 no_move++;
27454
27455
4/4
✓ Branch 0 taken 523305 times.
✓ Branch 1 taken 174060 times.
✓ Branch 2 taken 118501 times.
✓ Branch 3 taken 404804 times.
697365 if(scrolldir == up || scrolldir == down)
27456 {
27457
2/2
✓ Branch 0 taken 257384 times.
✓ Branch 1 taken 35177 times.
292561 if(!get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING))
27458 {
27459 //Add a few extra frames if on the second loop and cool scrolling is not set
27460
2/2
✓ Branch 0 taken 34695 times.
✓ Branch 1 taken 482 times.
35177 if(i == 1)
27461 {
27462 482 cx += (scrolldir == down) ? 3 : 2;
27463 482 no_move += (scrolldir == down) ? 3 : 2;
27464 482 }
27465 35177 }
27466 else
27467 {
27468 //4 frames after we've finished scrolling of being still
27469
4/4
✓ Branch 0 taken 9426 times.
✓ Branch 1 taken 247958 times.
✓ Branch 2 taken 4713 times.
✓ Branch 3 taken 4713 times.
257384 if(cx == 0 && !end_frames)
27470 {
27471 4713 cx += 4;
27472 4713 no_move += 4;
27473 4713 end_frames = true;
27474 4713 }
27475 }
27476 292561 }
27477
27478 //Move Hero and the scroll position
27479
2/2
✓ Branch 0 taken 64542 times.
✓ Branch 1 taken 632823 times.
697365 if(!no_move)
27480 {
27481
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 140444 times.
✓ Branch 2 taken 98627 times.
✓ Branch 3 taken 178353 times.
✓ Branch 4 taken 215399 times.
632823 switch(scrolldir)
27482 {
27483 case up:
27484 140444 sy -= step;
27485 140444 y += step;
27486 140444 break;
27487
27488 case down:
27489 98627 sy += step;
27490 98627 y -= step;
27491 98627 break;
27492
27493 case left:
27494 178353 sx -= step;
27495 178353 x += step;
27496 178353 break;
27497
27498 case right:
27499 215399 sx += step;
27500 215399 x -= step;
27501 215399 break;
27502 }
27503
27504 //bound Hero when me move him off the screen in the last couple of frames of scrolling
27505
2/2
✓ Branch 0 taken 12424 times.
✓ Branch 1 taken 620399 times.
632823 if(y > 160) y = 160;
27506
27507
2/2
✓ Branch 0 taken 8647 times.
✓ Branch 1 taken 624176 times.
632823 if(y < 0) y = 0;
27508
27509
2/2
✓ Branch 0 taken 11103 times.
✓ Branch 1 taken 621720 times.
632823 if(x > 240) x = 240;
27510
27511
2/2
✓ Branch 0 taken 13409 times.
✓ Branch 1 taken 619414 times.
632823 if(x < 0) x = 0;
27512
27513
4/4
✓ Branch 0 taken 632577 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 632567 times.
632823 if(ladderx > 0 || laddery > 0)
27514 {
27515 // If the ladder moves on both axes, the player can
27516 // gradually shift it by going back and forth
27517
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
27518 laddery = y.getInt();
27519 else
27520 256 ladderx = x.getInt();
27521 256 }
27522 632823 }
27523
27524 //Drawing
27525 697365 tx = sx;
27526 697365 ty = sy;
27527 697365 tx2 = sx;
27528 697365 ty2 = sy;
27529
27530
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 221427 times.
✓ Branch 2 taken 118501 times.
✓ Branch 3 taken 183377 times.
✓ Branch 4 taken 174060 times.
697365 switch(scrolldir)
27531 {
27532 case right:
27533 221427 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
27534 221427 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27535 221427 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
27536 221427 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27537 221427 tx -= 256;
27538 221427 break;
27539
27540 case down:
27541 118501 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27542 118501 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
27543 118501 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27544 118501 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
27545 118501 ty -= 176;
27546 118501 break;
27547
27548 case left:
27549 183377 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
27550 183377 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27551 183377 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
27552 183377 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27553 183377 tx2 -= 256;
27554 183377 break;
27555
27556 case up:
27557 174060 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27558 174060 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
27559 174060 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27560 174060 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
27561 174060 ty2 -= 176;
27562 174060 break;
27563 }
27564
27565 //FFScript.OnWaitdraw()
27566 697365 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
27567
27568 697365 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
27569 697365 clear_bitmap(scrollbuf);
27570 697365 clear_bitmap(framebuf);
27571 697365 clear_a5_bmp(rti_infolayer.bitmap);
27572
27573 697365 combotile_add_x = 0;
27574 697365 combotile_add_y = playing_field_offset;
27575
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 174060 times.
✓ Branch 2 taken 118501 times.
✓ Branch 3 taken 183377 times.
✓ Branch 4 taken 221427 times.
697365 switch(scrolldir)
27576 {
27577 case up:
27578
1/2
✓ Branch 0 taken 174060 times.
✗ Branch 1 not taken.
174060 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
27579
27580
1/2
✓ Branch 0 taken 174060 times.
✗ Branch 1 not taken.
174060 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
27581
27582
2/2
✓ Branch 0 taken 174043 times.
✓ Branch 1 taken 17 times.
174060 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
27583
27584
2/2
✓ Branch 0 taken 174043 times.
✓ Branch 1 taken 17 times.
174060 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
27585
27586 // Draw both screens' background layer primitives together, after both layers' combos.
27587 // Not ideal, but probably good enough for all realistic purposes.
27588
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 174060 times.
✓ Branch 2 taken 174060 times.
✗ Branch 3 not taken.
174060 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27589
27590
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 174043 times.
✓ Branch 2 taken 174043 times.
✓ Branch 3 taken 17 times.
174060 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27591
27592 174060 combotile_add_y -= sy;
27593 174060 putscr(scrollbuf, 0, 0, newscr);
27594 174060 putscr(scrollbuf, 0, 176, oldscr);
27595 174060 break;
27596
27597 case down:
27598
1/2
✓ Branch 0 taken 118501 times.
✗ Branch 1 not taken.
118501 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
27599
27600
1/2
✓ Branch 0 taken 118501 times.
✗ Branch 1 not taken.
118501 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
27601
27602
1/2
✓ Branch 0 taken 118501 times.
✗ Branch 1 not taken.
118501 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
27603
27604
1/2
✓ Branch 0 taken 118501 times.
✗ Branch 1 not taken.
118501 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
27605
27606
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 118501 times.
✓ Branch 2 taken 118501 times.
✗ Branch 3 not taken.
118501 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27607
27608
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 118501 times.
✓ Branch 2 taken 118501 times.
✗ Branch 3 not taken.
118501 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27609
27610 118501 combotile_add_y -= sy;
27611 118501 putscr(scrollbuf, 0, 0, oldscr);
27612 118501 putscr(scrollbuf, 0, 176, newscr);
27613 118501 break;
27614
27615 case left:
27616
1/2
✓ Branch 0 taken 183377 times.
✗ Branch 1 not taken.
183377 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
27617
27618
1/2
✓ Branch 0 taken 183377 times.
✗ Branch 1 not taken.
183377 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
27619
27620
2/2
✓ Branch 0 taken 183359 times.
✓ Branch 1 taken 18 times.
183377 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
27621
27622
2/2
✓ Branch 0 taken 183359 times.
✓ Branch 1 taken 18 times.
183377 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
27623
27624
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 183377 times.
✓ Branch 2 taken 183377 times.
✗ Branch 3 not taken.
183377 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27625
27626
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 183359 times.
✓ Branch 2 taken 183359 times.
✓ Branch 3 taken 18 times.
183377 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27627
27628 183377 combotile_add_x -= sx;
27629 183377 putscr(scrollbuf, 0, 0, newscr);
27630 183377 putscr(scrollbuf, 256, 0, oldscr);
27631 183377 break;
27632
27633 case right:
27634
1/2
✓ Branch 0 taken 221427 times.
✗ Branch 1 not taken.
221427 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
27635
27636
1/2
✓ Branch 0 taken 221427 times.
✗ Branch 1 not taken.
221427 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
27637
27638
1/2
✓ Branch 0 taken 221427 times.
✗ Branch 1 not taken.
221427 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
27639
27640
1/2
✓ Branch 0 taken 221427 times.
✗ Branch 1 not taken.
221427 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
27641
27642
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 221427 times.
✓ Branch 2 taken 221427 times.
✗ Branch 3 not taken.
221427 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27643
27644
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 221427 times.
✓ Branch 2 taken 221427 times.
✗ Branch 3 not taken.
221427 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27645
27646 221427 combotile_add_x -= sx;
27647 221427 putscr(scrollbuf, 0, 0, oldscr);
27648 221427 putscr(scrollbuf, 256, 0, newscr);
27649 221427 break;
27650 }
27651
27652 697365 combotile_add_x = 0;
27653 697365 combotile_add_y = 0;
27654
27655 697365 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
27656 697365 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
27657
27658 697365 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
27659 697365 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
27660
27661
2/2
✓ Branch 0 taken 648289 times.
✓ Branch 1 taken 49076 times.
697365 if(get_bit(quest_rules, qr_FFCSCROLL))
27662 {
27663 49076 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
27664 49076 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
27665 49076 }
27666
27667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697365 times.
697365 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
27668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697365 times.
697365 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
27669
27670 //push blocks
27671 697365 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
27672 697365 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
27673
2/2
✓ Branch 0 taken 689963 times.
✓ Branch 1 taken 7402 times.
697365 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
27674 {
27675 7402 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
27676 7402 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
27677 7402 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
27678 7402 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
27679 7402 }
27680
27681 697365 do_walkflags(oldscr, tx2, ty2,3); //show walkflags if the cheat is on
27682 697365 do_walkflags(newscr, tx, ty,2);
27683
27684 697365 do_effectflags(oldscr, tx2, ty2,3); //show effectflags if the cheat is on
27685 697365 do_effectflags(newscr, tx, ty,2);
27686
27687
27688 697365 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
27689 697365 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
27690 697365 herostep();
27691
1/2
✓ Branch 0 taken 697365 times.
✗ Branch 1 not taken.
697365 if(isForceFaceUp) dir = up;
27692
27693
5/6
✓ Branch 0 taken 697315 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 697265 times.
✓ Branch 4 taken 697315 times.
✓ Branch 5 taken 697315 times.
697365 if((z > 0 || fakez > 0) && (!get_bit(quest_rules,qr_SHADOWSFLICKER) || frame&1))
27694 {
27695 1394580 drawshadow(framebuf, get_bit(quest_rules, qr_TRANSSHADOWS) != 0);
27696 1394580 }
27697
27698
4/4
✓ Branch 0 taken 355399 times.
✓ Branch 1 taken 341966 times.
✓ Branch 2 taken 126247 times.
✓ Branch 3 taken 229152 times.
697365 if(!isdungeon() || get_bit(quest_rules,qr_FREEFORM))
27699 {
27700 468213 draw_under(framebuf); //draw the ladder or raft
27701 468213 decorations.draw2(framebuf, true);
27702 468213 draw(framebuf); //Hero
27703 468213 decorations.draw(framebuf, true);
27704 468213 }
27705
27706
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 697330 times.
697365 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
27707
27708 697365 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
27709 697365 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
27710
2/2
✓ Branch 0 taken 692850 times.
✓ Branch 1 taken 4515 times.
697365 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
27711 {
27712 4515 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
27713 4515 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
27714 4515 }
27715 697365 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
27716 697365 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
27717 697365 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
27718
27719
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 697330 times.
697365 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
27720
27721 697365 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
27722 697365 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
27723
2/2
✓ Branch 0 taken 692850 times.
✓ Branch 1 taken 4515 times.
697365 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
27724 {
27725 4515 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
27726 4515 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
27727 4515 }
27728 697365 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
27729 697365 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
27730 697365 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
27731
27732
27733
1/2
✓ Branch 0 taken 697365 times.
✗ Branch 1 not taken.
697365 if(msg_bg_display_buf->clip == 0)
27734 {
27735 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27736 }
27737
1/2
✓ Branch 0 taken 697365 times.
✗ Branch 1 not taken.
697365 if(msg_portrait_display_buf->clip == 0)
27738 {
27739 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27740 }
27741
1/2
✓ Branch 0 taken 697365 times.
✗ Branch 1 not taken.
697365 if(msg_txt_display_buf->clip == 0)
27742 {
27743 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27744 }
27745
27746
6/6
✓ Branch 0 taken 10809 times.
✓ Branch 1 taken 686556 times.
✓ Branch 2 taken 10583 times.
✓ Branch 3 taken 226 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 10500 times.
697365 if(get_bit(quest_rules, qr_NEW_DARKROOM) && ((newscr->flags&fDARK)||(oldscr->flags&fDARK)))
27747 {
27748 309 clear_to_color(darkscr_bmp_curscr, game->get_darkscr_color());
27749 309 clear_to_color(darkscr_bmp_curscr_trans, game->get_darkscr_color());
27750 309 clear_to_color(darkscr_bmp_scrollscr, game->get_darkscr_color());
27751 309 clear_to_color(darkscr_bmp_scrollscr_trans, game->get_darkscr_color());
27752 309 calc_darkroom_combos(true);
27753 309 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
27754 309 }
27755
27756
4/4
✓ Branch 0 taken 10809 times.
✓ Branch 1 taken 686556 times.
✓ Branch 2 taken 7290 times.
✓ Branch 3 taken 3519 times.
697365 if(get_bit(quest_rules, qr_NEW_DARKROOM) && get_bit(quest_rules, qr_NEWDARK_L6))
27757 {
27758 3519 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
27759 3519 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
27760 3519 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
27761
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(newscr->flags & fDARK)
27762 {
27763 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27764 {
27765 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
27766 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27767 }
27768
27769 color_map = &trans_table2;
27770 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27771 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
27772 else
27773 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
27774 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
27775 color_map = &trans_table;
27776 }
27777
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(oldscr->flags & fDARK)
27778 {
27779 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27780 {
27781 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
27782 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27783 }
27784
27785 color_map = &trans_table2;
27786 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27787 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
27788 else
27789 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
27790 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
27791 color_map = &trans_table;
27792 }
27793 3519 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
27794 3519 }
27795 697365 put_passive_subscr(framebuf, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
27796
2/2
✓ Branch 0 taken 520438 times.
✓ Branch 1 taken 176927 times.
697365 if(get_bit(quest_rules,qr_SUBSCREENOVERSPRITES))
27797 176927 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
27798
27799
4/4
✓ Branch 0 taken 10809 times.
✓ Branch 1 taken 686556 times.
✓ Branch 2 taken 7290 times.
✓ Branch 3 taken 3519 times.
697365 if(get_bit(quest_rules, qr_NEW_DARKROOM) && !get_bit(quest_rules, qr_NEWDARK_L6))
27800 {
27801 7290 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
27802 7290 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
27803 7290 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
27804
2/2
✓ Branch 0 taken 7064 times.
✓ Branch 1 taken 226 times.
7290 if(newscr->flags & fDARK)
27805 {
27806
1/2
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
226 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27807 {
27808 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
27809 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27810 }
27811
27812 226 color_map = &trans_table2;
27813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27814 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
27815 else
27816 226 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
27817 226 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
27818 226 color_map = &trans_table;
27819 226 }
27820
2/2
✓ Branch 0 taken 7081 times.
✓ Branch 1 taken 209 times.
7290 if(oldscr->flags & fDARK)
27821 {
27822
1/2
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
209 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27823 {
27824 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
27825 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27826 }
27827
27828 209 color_map = &trans_table2;
27829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27830 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
27831 else
27832 209 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
27833 209 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
27834 209 color_map = &trans_table;
27835 209 }
27836 7290 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
27837 7290 }
27838 697365 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
27839
27840 //end drawing
27841 697365 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27842 697365 advanceframe(true/*,true,false*/);
27843
27844 //Don't clear the last frame, unless 'fixed'
27845
4/4
✓ Branch 0 taken 10721 times.
✓ Branch 1 taken 686644 times.
✓ Branch 2 taken 219 times.
✓ Branch 3 taken 10502 times.
697365 if(cx > 0 || get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
27846 686863 script_drawing_commands.Clear();
27847 697365 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27848 697365 actiontype lastaction = action;
27849 697365 action=scrolling; FFCore.setHeroAction(scrolling);
27850 697365 FFCore.runF6Engine();
27851 697365 action=lastaction; FFCore.setHeroAction(lastaction);
27852 697365 } //end main scrolling loop
27853 10721 currdmap = olddmap;
27854
27855 10721 clear_bitmap(msg_txt_display_buf);
27856 10721 set_clip_state(msg_txt_display_buf, 1);
27857 10721 clear_bitmap(msg_bg_display_buf);
27858 10721 set_clip_state(msg_bg_display_buf, 1);
27859 10721 clear_bitmap(msg_portrait_display_buf);
27860 10721 set_clip_state(msg_portrait_display_buf, 1);
27861
27862 //Move hero to the other side of the screen if scrolling's not turned on
27863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10721 times.
10721 if(get_bit(quest_rules, qr_NOSCROLL))
27864 {
27865 switch(scrolldir)
27866 {
27867 case up:
27868 y = 160;
27869 break;
27870
27871 case down:
27872 y = 0;
27873 break;
27874
27875 case left:
27876 x = 240;
27877 break;
27878
27879 case right:
27880 x = 0;
27881 break;
27882 }
27883 }
27884
27885
3/4
✓ Branch 0 taken 10720 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 10721 times.
✗ Branch 3 not taken.
10721 if((z > 0 || fakez > 0) && isSideViewHero())
27886 {
27887 y -= z;
27888 y -= fakez;
27889 z = 0;
27890 fakez = 0;
27891 }
27892
27893 10721 combotile_add_x = 0;
27894 10721 combotile_add_y = 0;
27895
27896 10721 set_respawn_point(false);
27897 10721 trySideviewLadder();
27898 10721 warpx = -1;
27899 10721 warpy = -1;
27900
27901 10721 screenscrolling = false;
27902 10721 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
27903 10721 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27904 10721 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27905 10721 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27906 10721 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27907
27908
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 10406 times.
10721 if(destdmap != -1)
27909 {
27910 315 bool changedlevel = false;
27911 315 bool changeddmap = false;
27912
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 226 times.
315 if(olddmap != destdmap)
27913 {
27914 226 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
27915 226 changeddmap = true;
27916 226 }
27917
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 79 times.
315 if(DMaps[olddmap].level != DMaps[destdmap].level)
27918 {
27919 79 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
27920 79 changedlevel = true;
27921 79 }
27922 315 dlevel = DMaps[destdmap].level;
27923 315 currdmap = destdmap;
27924
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 226 times.
315 if(changeddmap)
27925 {
27926 226 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
27927 226 }
27928
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 79 times.
315 if(changedlevel)
27929 {
27930 79 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
27931 79 }
27932 315 }
27933
27934 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
27935 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
27936 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
27937 //direction. -DD
27938
27939
2/2
✓ Branch 0 taken 10565 times.
✓ Branch 1 taken 156 times.
10721 if(nowinwater)
27940 {
27941 156 SetSwim();
27942 156 hopclk = 0xFF;
27943 156 }
27944
27945 // NES behaviour: Fade to light after scrolling
27946 10721 lighting(false, false); // No, we don't need to set naturaldark...
27947
27948 10721 init_dmap();
27949 10721 putscr(scrollbuf,0,0,newscr);
27950 10721 putscrdoors(scrollbuf,0,0,newscr);
27951
27952 // Check for raft flags
27953
6/6
✓ Branch 0 taken 10525 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 10369 times.
✓ Branch 3 taken 156 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 10318 times.
10721 if(action!=rafting && hopclk==0 && !toogam)
27954 {
27955
3/4
✓ Branch 0 taken 10315 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10315 times.
10318 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
27956 {
27957 3 sfx(tmpscr->secretsfx);
27958 3 action=rafting; FFCore.setHeroAction(rafting);
27959 3 raftclk=0;
27960 3 }
27961
27962 // Half a tile off?
27963
6/8
✓ Branch 0 taken 7771 times.
✓ Branch 1 taken 2544 times.
✓ Branch 2 taken 3002 times.
✓ Branch 3 taken 4769 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5546 times.
✓ Branch 6 taken 10315 times.
✗ Branch 7 not taken.
15861 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
27964 {
27965 sfx(tmpscr->secretsfx);
27966 action=rafting; FFCore.setHeroAction(rafting);
27967 raftclk=0;
27968 }
27969 10318 }
27970
27971 10721 opendoors=0;
27972 10721 markBmap(-1);
27973
27974
2/2
✓ Branch 0 taken 6300 times.
✓ Branch 1 taken 4421 times.
10721 if(isdungeon())
27975 {
27976
3/3
✓ Branch 0 taken 2562 times.
✓ Branch 1 taken 1145 times.
✓ Branch 2 taken 714 times.
4421 switch(tmpscr->door[scrolldir^1])
27977 {
27978 case dOPEN:
27979 case dUNLOCKED:
27980 case dOPENBOSS:
27981 2562 dir = scrolldir;
27982
27983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2562 times.
2562 if(action!=rafting)
27984 2562 stepforward(diagonalMovement?11:12, false);
27985
27986 2562 break;
27987
27988 case dSHUTTER:
27989 case d1WAYSHUTTER:
27990 1145 dir = scrolldir;
27991
27992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1145 times.
1145 if(action!=rafting)
27993 1145 stepforward(diagonalMovement?21:24, false);
27994
27995 1145 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
27996 1145 opendoors=-4;
27997 1145 sfx(WAV_DOOR);
27998 1145 break;
27999
28000 default:
28001 714 dir = scrolldir;
28002
28003
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 667 times.
714 if(action!=rafting)
28004 667 stepforward(diagonalMovement?21:24, false);
28005 714 }
28006 4421 }
28007
28008
1/2
✓ Branch 0 taken 10721 times.
✗ Branch 1 not taken.
10721 if(isForceFaceUp) dir = up;
28009
28010
1/2
✓ Branch 0 taken 10721 times.
✗ Branch 1 not taken.
10721 if(action == scrolling)
28011 {
28012 action=none; FFCore.setHeroAction(none);
28013 }
28014
28015
2/4
✓ Branch 0 taken 10721 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10721 times.
10721 if(action != attacking && action != sideswimattacking)
28016 {
28017 10721 charging = 0;
28018 10721 tapping = false;
28019 10721 }
28020
28021 10721 map_bkgsfx(true);
28022
28023
2/2
✓ Branch 0 taken 10694 times.
✓ Branch 1 taken 27 times.
10721 if(newscr->flags2&fSECRET)
28024 {
28025 27 sfx(newscr->secretsfx);
28026 27 }
28027
28028 10721 playLevelMusic();
28029
28030 10721 newscr_clk = frame;
28031 10721 activated_timed_warp=false;
28032 10721 loadside = scrolldir^1;
28033 10721 FFCore.clear_combo_scripts();
28034 10721 eventlog_mapflags();
28035 10721 decorations.animate(); //continue to animate tall grass during scrolling
28036
2/2
✓ Branch 0 taken 10502 times.
✓ Branch 1 taken 219 times.
10721 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
28037 {
28038
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 213 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
219 if(olddmap == newdmap || (replay_is_active() && replay_get_version() < 15))
28039 219 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
28040 else refresh_dmap_scrollscript = true;
28041 219 }
28042
1/2
✓ Branch 0 taken 10721 times.
✗ Branch 1 not taken.
10721 if(!get_bit(quest_rules,qr_SCROLLWARP_NO_RESET_FRAME))
28043 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
28044 10721 }
28045
28046
28047
28048 // How much to reduce Hero's damage, taking into account various rings.
28049 6818 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
28050 {
28051
1/2
✓ Branch 0 taken 6818 times.
✗ Branch 1 not taken.
6818 if(dmg < 0) return dmg; //Don't reduce healing
28052
2/2
✓ Branch 0 taken 6690 times.
✓ Branch 1 taken 128 times.
6818 if ( get_bit(quest_rules,qr_BROKEN_RING_POWER) )
28053 {
28054 6690 int32_t divisor = 1;
28055 6690 float percentage = 1;
28056 6690 int32_t itemid = current_item_id(itype_ring);
28057 6690 bool usering = false;
28058
28059
4/4
✓ Branch 0 taken 4845 times.
✓ Branch 1 taken 1845 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 4808 times.
6690 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
28060 {
28061 4808 usering = true;
28062 4808 paymagiccost(itemid);
28063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4808 times.
4808 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28064 {
28065 percentage *= itemsbuf[itemid].power/100.0;
28066 }
28067 else
28068 {
28069 4808 divisor *= itemsbuf[itemid].power;
28070 }
28071 4808 }
28072
28073 /* Now for the Peril Ring */
28074 6690 itemid = current_item_id(itype_perilring);
28075
28076
7/10
✓ Branch 0 taken 502 times.
✓ Branch 1 taken 6188 times.
✓ Branch 2 taken 502 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 427 times.
✓ Branch 6 taken 75 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 75 times.
6690 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
28077 {
28078 75 usering = true;
28079 75 paymagiccost(itemid);
28080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28081 {
28082 percentage *= itemsbuf[itemid].power/100.0;
28083 }
28084 else
28085 {
28086 75 divisor *= itemsbuf[itemid].power;
28087 }
28088 75 }
28089
28090 // Ring divisor of 0 = no damage. -L
28091
4/6
✓ Branch 0 taken 4815 times.
✓ Branch 1 taken 1875 times.
✓ Branch 2 taken 4815 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4815 times.
6690 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
28092 return 0;
28093
28094
1/2
✓ Branch 0 taken 6690 times.
✗ Branch 1 not taken.
6690 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
28095
28096
1/2
✓ Branch 0 taken 6690 times.
✗ Branch 1 not taken.
6690 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
28097
1/2
✓ Branch 0 taken 6690 times.
✗ Branch 1 not taken.
6690 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
28098
28099 }
28100 else
28101 {
28102 128 double divisor = 1;
28103 128 double percentage = 1;
28104 128 int32_t itemid = current_item_id(itype_ring);
28105 128 bool usering = false;
28106
28107
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
128 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
28108 {
28109 3 usering = true;
28110 3 paymagiccost(itemid);
28111
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28112 {
28113 1 double perc = itemsbuf[itemid].power/100.0;
28114
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
28115 1 percentage *= perc;
28116 1 }
28117 else
28118 {
28119
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].power < 0)
28120 divisor /= -(itemsbuf[itemid].power);
28121 2 else divisor *= itemsbuf[itemid].power;
28122 }
28123 3 }
28124
28125 /* Now for the Peril Ring */
28126 128 itemid = current_item_id(itype_perilring);
28127
28128
4/10
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
128 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
28129 {
28130 usering = true;
28131 paymagiccost(itemid);
28132 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28133 {
28134 double perc = itemsbuf[itemid].power/100.0;
28135 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
28136 percentage *= perc;
28137 }
28138 else
28139 {
28140 if(itemsbuf[itemid].power < 0)
28141 divisor /= -(itemsbuf[itemid].power);
28142 else divisor *= itemsbuf[itemid].power;
28143 }
28144 }
28145
28146 // Ring divisor of 0 = no damage. -L
28147
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
128 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
28148 return 0;
28149
28150 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
28151
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
28152 }
28153 6818 }
28154
28155 // Should swinging the hammer make the 'pound' sound?
28156 // Or is Hero just hitting air?
28157 2216 bool HeroClass::sideviewhammerpound()
28158 {
28159 2216 int32_t wx=0,wy=0;
28160
28161
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 638 times.
✓ Branch 4 taken 740 times.
2216 switch(dir)
28162 {
28163 case up:
28164 350 wx=-1;
28165 350 wy=-15;
28166
28167
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(isSideViewHero()) wy+=8;
28168
28169 350 break;
28170
28171 case down:
28172 488 wx=8;
28173 488 wy=28;
28174
28175
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(isSideViewHero()) wy-=8;
28176
28177 488 break;
28178
28179 case left:
28180 638 wx=-8;
28181 638 wy=14;
28182
28183
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 6 times.
638 if(isSideViewHero()) wy+=8;
28184
28185 638 break;
28186
28187 case right:
28188 740 wx=21;
28189 740 wy=14;
28190
28191
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(isSideViewHero()) wy+=8;
28192
28193 740 break;
28194 }
28195
28196
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2210 times.
2216 if(!isSideViewHero())
28197 {
28198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2210 times.
2210 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
28199 }
28200
28201
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
28202
28203 if(dir==left || dir==right)
28204 {
28205 wx+=16;
28206
28207 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
28208 }
28209
28210 return false;
28211 2216 }
28212
28213 /************************************/
28214 /******** More Items Code *********/
28215 /************************************/
28216
28217 // The following are only used for Hero damage. Damage is in quarter hearts.
28218 3789 int32_t enemy_dp(int32_t index)
28219 {
28220 3789 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
28221 }
28222
28223 2890 int32_t ewpn_dp(int32_t index)
28224 {
28225 2890 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
28226 }
28227
28228 27 int32_t lwpn_dp(int32_t index)
28229 {
28230 27 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
28231 }
28232
28233 93395117 bool checkbunny(int32_t itemid)
28234 {
28235
3/4
✓ Branch 0 taken 93290451 times.
✓ Branch 1 taken 104666 times.
✓ Branch 2 taken 104666 times.
✗ Branch 3 not taken.
93395117 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
28236 }
28237
28238 22458415 bool usesSwordJinx(int32_t itemid)
28239 {
28240 22458415 itemdata const& it = itemsbuf[itemid];
28241 22458415 bool ret = (it.family==itype_sword);
28242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22458415 times.
22458415 if(it.flags & ITEM_FLIP_JINX) return !ret;
28243 22458415 return ret;
28244 22458415 }
28245 20073245 bool checkitem_jinx(int32_t itemid)
28246 {
28247 20073245 itemdata const& it = itemsbuf[itemid];
28248
2/2
✓ Branch 0 taken 1416 times.
✓ Branch 1 taken 20071829 times.
20073245 if(it.flags & ITEM_JINX_IMMUNE) return true;
28249
2/2
✓ Branch 0 taken 5408047 times.
✓ Branch 1 taken 14663782 times.
20071829 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
28250 14663782 return HeroItemClk() == 0;
28251 20073245 }
28252
28253 373535 int32_t Bweapon(int32_t pos)
28254 {
28255
4/4
✓ Branch 0 taken 373533 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 756 times.
✓ Branch 3 taken 372777 times.
373535 if(pos < 0 || current_subscreen_active == NULL)
28256 {
28257 758 return 0;
28258 }
28259
28260 372777 int32_t p=-1;
28261
28262
4/4
✓ Branch 0 taken 104066 times.
✓ Branch 1 taken 10851770 times.
✓ Branch 2 taken 104066 times.
✓ Branch 3 taken 10851770 times.
10955836 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL && i < MAXSUBSCREENITEMS; ++i)
28263 {
28264
4/4
✓ Branch 0 taken 7838192 times.
✓ Branch 1 taken 3013578 times.
✓ Branch 2 taken 7569481 times.
✓ Branch 3 taken 268711 times.
10851770 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM && current_subscreen_active->objects[i].d3==pos)
28265 {
28266 268711 p=i;
28267 268711 break;
28268 }
28269 10583059 }
28270
28271
2/2
✓ Branch 0 taken 268711 times.
✓ Branch 1 taken 104066 times.
372777 if(p==-1)
28272 {
28273 104066 return 0;
28274 }
28275
28276 268711 int32_t actualItem = current_subscreen_active->objects[p].d8;
28277 //int32_t familyCheck = actualItem ? itemsbuf[actualItem].family : current_subscreen_active->objects[p].d1
28278 268711 int32_t family = -1;
28279 268711 bool bow = false;
28280
28281
2/2
✓ Branch 0 taken 9486 times.
✓ Branch 1 taken 259225 times.
268711 if(actualItem)
28282 {
28283 9486 bool select = false;
28284
28285
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6222 times.
9486 switch(itemsbuf[actualItem-1].family)
28286 {
28287 case itype_bomb:
28288 if((game->get_bombs() ||
28289 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28290 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitBomb))) ||
28291 current_item_power(itype_bombbag))
28292 {
28293 select=true;
28294 }
28295
28296 break;
28297
28298 case itype_bowandarrow:
28299 case itype_arrow:
28300 if(actualItem-1>-1 && current_item_id(itype_bow)>-1)
28301 {
28302 //bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
28303 select=true;
28304 }
28305
28306 break;
28307
28308 case itype_letterpotion:
28309 /*if(current_item_id(itype_potion)>-1)
28310 {
28311 select=true;
28312 }
28313 else if(current_item_id(itype_letter)>-1)
28314 {
28315 select=true;
28316 }*/
28317 break;
28318
28319 case itype_sbomb:
28320 {
28321 int32_t bombbagid = current_item_id(itype_bombbag);
28322
28323 if((game->get_sbombs() ||
28324 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28325 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitSBomb))) ||
28326 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
28327 {
28328 select=true;
28329 }
28330
28331 break;
28332 }
28333
28334 case itype_sword:
28335 {
28336
1/2
✓ Branch 0 taken 6222 times.
✗ Branch 1 not taken.
6222 if(!get_bit(quest_rules,qr_SELECTAWPN))
28337 break;
28338
28339 6222 select=true;
28340 }
28341 6222 break;
28342
28343 default:
28344 3264 select=true;
28345 3264 }
28346
28347
4/6
✓ Branch 0 taken 9486 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7619 times.
✓ Branch 3 taken 1867 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7619 times.
9486 if(!item_disabled(actualItem-1) && game->get_item(actualItem-1) && select)
28348 {
28349 7619 directItem = actualItem-1;
28350
28351
2/4
✓ Branch 0 taken 7619 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7619 times.
✗ Branch 3 not taken.
7619 if(directItem>-1 && itemsbuf[directItem].family == itype_arrow) bow=true;
28352
28353 7619 return actualItem-1+(bow?0xF000:0);
28354 }
28355 1867 else return 0;
28356 }
28357
28358 259225 directItem = -1;
28359
28360
6/6
✓ Branch 0 taken 26017 times.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 213871 times.
✓ Branch 3 taken 10598 times.
✓ Branch 4 taken 4069 times.
✓ Branch 5 taken 1467 times.
259225 switch(current_subscreen_active->objects[p].d1)
28361 {
28362 case itype_bomb:
28363 {
28364 26017 int32_t bombid = current_item_id(itype_bomb);
28365
28366
4/4
✓ Branch 0 taken 5619 times.
✓ Branch 1 taken 20398 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 5586 times.
31636 if((game->get_bombs() ||
28367 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28368
3/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 5531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
5619 (bombid>-1 && itemsbuf[bombid].misc1==0 && Lwpns.idCount(wLitBomb)>0)) ||
28369 5619 current_item_power(itype_bombbag))
28370 {
28371 20431 family=itype_bomb;
28372 20431 }
28373
28374 26017 break;
28375 }
28376
28377 case itype_bowandarrow:
28378 case itype_arrow:
28379
4/4
✓ Branch 0 taken 8957 times.
✓ Branch 1 taken 1641 times.
✓ Branch 2 taken 8956 times.
✓ Branch 3 taken 1 times.
10598 if(current_item_id(itype_bow)>-1 && current_item_id(itype_arrow)>-1)
28380 {
28381 8956 bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
28382 8956 family=itype_arrow;
28383 8956 }
28384
28385 10598 break;
28386
28387 case itype_letterpotion:
28388
2/2
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 2066 times.
4069 if(current_item_id(itype_potion)>-1)
28389 {
28390 2003 family=itype_potion;
28391 2003 }
28392
2/2
✓ Branch 0 taken 1577 times.
✓ Branch 1 taken 489 times.
2066 else if(current_item_id(itype_letter)>-1)
28393 {
28394 489 family=itype_letter;
28395 489 }
28396
28397 4069 break;
28398
28399 case itype_sbomb:
28400 {
28401 3203 int32_t bombbagid = current_item_id(itype_bombbag);
28402 3203 int32_t sbombid = current_item_id(itype_sbomb);
28403
28404
3/4
✓ Branch 0 taken 1466 times.
✓ Branch 1 taken 1737 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
3213 if((game->get_sbombs() ||
28405 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28406
3/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 1397 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
1466 (sbombid>-1 && itemsbuf[sbombid].misc1==0 && Lwpns.idCount(wLitSBomb)>0)) ||
28407
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1456 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
1466 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
28408 {
28409 1747 family=itype_sbomb;
28410 1747 }
28411
28412 3203 break;
28413 }
28414
28415 case itype_sword:
28416 {
28417
2/2
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 30 times.
1467 if(!get_bit(quest_rules,qr_SELECTAWPN))
28418 30 break;
28419
28420 1437 family=itype_sword;
28421 }
28422 1437 break;
28423
28424 default:
28425 213871 family=current_subscreen_active->objects[p].d1;
28426 213871 }
28427
28428
2/2
✓ Branch 0 taken 248934 times.
✓ Branch 1 taken 10291 times.
259225 if(family==-1)
28429 10291 return 0;
28430
28431
2/2
✓ Branch 0 taken 12432816 times.
✓ Branch 1 taken 19401 times.
12452217 for(int32_t j=0; j<MAXITEMS; j++)
28432 {
28433 // Find the item that matches this subscreen object.
28434
5/6
✓ Branch 0 taken 423182 times.
✓ Branch 1 taken 12009634 times.
✓ Branch 2 taken 229533 times.
✓ Branch 3 taken 193649 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 229533 times.
12432816 if(itemsbuf[j].family==family && j == current_item_id(family,false) && !item_disabled(j))
28435 {
28436 229533 return j+(bow?0xF000:0);
28437 }
28438 12203283 }
28439
28440 19401 return 0;
28441 373535 }
28442
28443 93 int32_t BWeapon_to_Pos(int32_t bweapon)
28444 {
28445
2/2
✓ Branch 0 taken 5272 times.
✓ Branch 1 taken 19 times.
5291 for (int32_t i = 0; i < MAXSUBSCREENITEMS; ++i)
28446 {
28447
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 5198 times.
5272 if (Bweapon(i) == bweapon)
28448 {
28449 74 return i;
28450 }
28451 5198 }
28452 19 return -1;
28453 93 }
28454
28455 2 void stopCaneOfByrna()
28456 {
28457
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
42 for(int32_t i=0; i<Lwpns.Count(); i++)
28458 {
28459 40 weapon *w = ((weapon*)Lwpns.spr(i));
28460
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2 times.
40 if(w->id==wCByrna)
28461 2 w->dead=1;
28462 40 }
28463 2 }
28464
28465 /* Crashes if used by ffscript.cpp, in case LINKITEMD
28466 void stopCaneOfByrna()
28467 {
28468 byte prnt_cane = -1;
28469 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
28470 prnt_cane = ew->parentitem;
28471 for(int32_t i=0; i<Lwpns.Count(); i++)
28472 {
28473 weapon *w = ((weapon*)Lwpns.spr(i));
28474
28475 if(w->id==wCByrna)
28476 {
28477 w->dead=1;
28478 }
28479 }
28480 if ( prnt_cane > -1 )
28481 {
28482 stop_sfx(itemsbuf[prnt_cane].usesound);
28483 }
28484 }
28485 */
28486 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
28487 6404872 void HeroClass::cleanupByrna()
28488 {
28489
2/2
✓ Branch 0 taken 6404795 times.
✓ Branch 1 taken 77 times.
6404872 if ( last_cane_of_byrna_item_id > -1 )
28490 {
28491 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
28492
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 75 times.
77 if ( !(Lwpns.idCount(wCByrna)) )
28493 {
28494 2 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
28495 2 last_cane_of_byrna_item_id = -1;
28496 2 }
28497 77 }
28498 6404872 }
28499
28500 // Used to find out if an item family is attached to one of the buttons currently pressed.
28501 2071446 bool isWpnPressed(int32_t itype)
28502 {
28503 //0xFFF for subscreen overrides
28504 //Will crash on win10 without it! -Z
28505
4/4
✓ Branch 0 taken 403821 times.
✓ Branch 1 taken 1667625 times.
✓ Branch 2 taken 368537 times.
✓ Branch 3 taken 35284 times.
2071446 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return true;
28506
4/4
✓ Branch 0 taken 713065 times.
✓ Branch 1 taken 1323097 times.
✓ Branch 2 taken 285153 times.
✓ Branch 3 taken 427912 times.
2036162 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return true;
28507
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1608250 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1608250 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return true;
28508
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1608230 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
1608250 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return true;
28509 1608230 return false;
28510 2071446 }
28511
28512 3700425 int32_t getWpnPressed(int32_t itype)
28513 {
28514
4/4
✓ Branch 0 taken 177199 times.
✓ Branch 1 taken 3523226 times.
✓ Branch 2 taken 171856 times.
✓ Branch 3 taken 5343 times.
3700425 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
28515
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3694496 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 586 times.
3695082 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
28516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3694496 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3694496 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
28517
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3694496 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3694496 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
28518
28519 3694496 return -1;
28520 3700425 }
28521
28522 6406501 int32_t getRocsPressed()
28523 {
28524 6406501 int32_t jumpid = current_item_id(itype_rocs,true,true);
28525
28526
2/2
✓ Branch 0 taken 184646 times.
✓ Branch 1 taken 6221855 times.
6406501 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
28527
28528
2/2
✓ Branch 0 taken 6221855 times.
✓ Branch 1 taken 184646 times.
6406501 if (jumpid != -1)
28529 {
28530 184646 itemdata const& itm = itemsbuf[jumpid];
28531
28532 184646 byte intbtn = byte(itm.misc2&0xFF);
28533
1/2
✓ Branch 0 taken 184646 times.
✗ Branch 1 not taken.
184646 if(getIntBtnInput(intbtn, false, true, false, false, true))
28534 return jumpid; //not pressed
28535 184646 }
28536
28537
4/4
✓ Branch 0 taken 4610 times.
✓ Branch 1 taken 6401891 times.
✓ Branch 2 taken 4306 times.
✓ Branch 3 taken 304 times.
6406501 if((itype_rocs==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
28538
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6406197 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6406197 if((itype_rocs==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
28539
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6406197 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6406197 if((itype_rocs==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
28540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6406197 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6406197 if((itype_rocs==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
28541
28542 6406197 return -1;
28543 6406501 }
28544
28545 bool isItmPressed(int32_t itmid)
28546 {
28547 if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
28548 if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
28549 if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
28550 if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
28551 return false;
28552 }
28553
28554 781 void selectNextAWpn(int32_t type)
28555 {
28556
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(!get_bit(quest_rules,qr_SELECTAWPN))
28557 return;
28558
28559
2/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
781 int32_t ret = selectWpn_new(type, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28560 781 Awpn = Bweapon(ret);
28561 781 directItemA = directItem;
28562 781 game->awpn = ret;
28563 781 }
28564
28565 7560 void selectNextBWpn(int32_t type)
28566 {
28567
2/4
✓ Branch 0 taken 7560 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7560 times.
7560 int32_t ret = selectWpn_new(type, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28568 7560 Bwpn = Bweapon(ret);
28569 7560 directItemB = directItem;
28570 7560 game->bwpn = ret;
28571 7560 }
28572
28573 void selectNextXWpn(int32_t type)
28574 {
28575 if(!get_bit(quest_rules,qr_SET_XBUTTON_ITEMS)) return;
28576 int32_t ret = selectWpn_new(type, game->xwpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28577 Xwpn = Bweapon(ret);
28578 directItemX = directItem;
28579 game->xwpn = ret;
28580 }
28581
28582 void selectNextYWpn(int32_t type)
28583 {
28584 if(!get_bit(quest_rules,qr_SET_YBUTTON_ITEMS)) return;
28585 int32_t ret = selectWpn_new(type, game->ywpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
28586 Ywpn = Bweapon(ret);
28587 directItemY = directItem;
28588 game->ywpn = ret;
28589 }
28590
28591 50887 void verifyAWpn()
28592 {
28593
2/2
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 49868 times.
50887 if ( (game->forced_awpn != -1) )
28594 {
28595 1019 return;
28596 }
28597
2/2
✓ Branch 0 taken 46039 times.
✓ Branch 1 taken 3829 times.
49868 if(!get_bit(quest_rules,qr_SELECTAWPN))
28598 {
28599 46039 Awpn = selectSword();
28600 46039 game->awpn = 0xFF;
28601 46039 }
28602 else
28603 {
28604 3829 game->awpn = selectWpn_new(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
28605 3829 Awpn = Bweapon(game->awpn);
28606 3829 directItemA = directItem;
28607 }
28608 50887 }
28609
28610 48522 void verifyBWpn()
28611 {
28612
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 47509 times.
48522 if ( (game->forced_bwpn != -1) )
28613 {
28614 1013 return;
28615 }
28616 47509 game->bwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
28617 47509 Bwpn = Bweapon(game->bwpn);
28618 47509 directItemB = directItem;
28619 48522 }
28620
28621 48522 void verifyXWpn()
28622 {
28623
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 47509 times.
48522 if ( (game->forced_xwpn != -1) )
28624 {
28625 1013 return;
28626 }
28627
2/2
✓ Branch 0 taken 47445 times.
✓ Branch 1 taken 64 times.
47509 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
28628 64 game->xwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
28629 47445 else game->xwpn = -1;
28630 47509 Xwpn = Bweapon(game->xwpn);
28631 47509 directItemX = directItem;
28632 48522 }
28633
28634 48522 void verifyYWpn()
28635 {
28636
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 47509 times.
48522 if ( (game->forced_ywpn != -1) )
28637 {
28638 1013 return;
28639 }
28640
2/2
✓ Branch 0 taken 47445 times.
✓ Branch 1 taken 64 times.
47509 if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS))
28641 64 game->ywpn = selectWpn_new(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
28642 47445 else game->ywpn = -1;
28643 47509 Ywpn = Bweapon(game->ywpn);
28644 47509 directItemY = directItem;
28645 48522 }
28646
28647 48522 void verifyBothWeapons()
28648 {
28649 48522 verifyAWpn();
28650 48522 verifyBWpn();
28651 48522 verifyXWpn();
28652 48522 verifyYWpn();
28653 48522 }
28654
28655 61448 int32_t selectWpn_new(int32_t type, int32_t startpos, int32_t forbiddenpos, int32_t fp2, int32_t fp3)
28656 {
28657 //what will be returned when all else fails.
28658 //don't return the forbiddenpos... no matter what -DD
28659
28660 61448 int32_t failpos(0);
28661
28662
6/6
✓ Branch 0 taken 59007 times.
✓ Branch 1 taken 2441 times.
✓ Branch 2 taken 58843 times.
✓ Branch 3 taken 164 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 58839 times.
61448 if(startpos == forbiddenpos || startpos == fp2 || startpos == fp3)
28663 2609 failpos = 0xFF;
28664 58839 else failpos = startpos;
28665
28666 // verify startpos
28667
3/4
✓ Branch 0 taken 61448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2620 times.
✓ Branch 3 taken 58828 times.
61448 if(startpos < 0 || startpos >= 0xFF)
28668 2620 startpos = 0;
28669
28670
2/2
✓ Branch 0 taken 61182 times.
✓ Branch 1 taken 266 times.
61448 if(current_subscreen_active == NULL)
28671 266 return failpos;
28672
28673
4/4
✓ Branch 0 taken 9871 times.
✓ Branch 1 taken 51311 times.
✓ Branch 2 taken 721 times.
✓ Branch 3 taken 9150 times.
61182 if(type==SEL_VERIFY_RIGHT || type==SEL_VERIFY_LEFT)
28674 {
28675 52032 int32_t wpn = Bweapon(startpos);
28676
28677
6/8
✓ Branch 0 taken 48517 times.
✓ Branch 1 taken 3515 times.
✓ Branch 2 taken 48496 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 48496 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 48496 times.
52032 if(wpn != 0 && startpos != forbiddenpos && startpos != fp2 && startpos != fp3)
28678 {
28679 48496 return startpos;
28680 }
28681 3536 }
28682
28683 12686 int32_t p=-1;
28684 12686 int32_t curpos = startpos;
28685 12686 int32_t firstValidPos=-1;
28686
28687
2/2
✓ Branch 0 taken 2111 times.
✓ Branch 1 taken 277550 times.
279661 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
28688 {
28689
2/2
✓ Branch 0 taken 79559 times.
✓ Branch 1 taken 197991 times.
277550 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
28690 {
28691
4/4
✓ Branch 0 taken 156867 times.
✓ Branch 1 taken 41124 times.
✓ Branch 2 taken 146292 times.
✓ Branch 3 taken 10575 times.
197991 if(firstValidPos==-1 && current_subscreen_active->objects[i].d3>=0)
28692 {
28693 10575 firstValidPos=i;
28694 10575 }
28695
28696
2/2
✓ Branch 0 taken 187416 times.
✓ Branch 1 taken 10575 times.
197991 if(current_subscreen_active->objects[i].d3==curpos)
28697 {
28698 10575 p=i;
28699 10575 break;
28700 }
28701 187416 }
28702 266975 }
28703
28704
2/2
✓ Branch 0 taken 10575 times.
✓ Branch 1 taken 2111 times.
12686 if(p == -1)
28705 {
28706 //can't find the current position
28707 // Switch to a valid weapon if there is one; otherwise,
28708 // the selector can simply disappear
28709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2111 times.
2111 if(firstValidPos>=0)
28710 {
28711 return current_subscreen_active->objects[firstValidPos].d3;
28712 }
28713 //FAILURE
28714 else
28715 {
28716 2111 return failpos;
28717 }
28718 }
28719
28720 //remember we've been here
28721 10575 set<int32_t> oldPositions;
28722
1/2
✓ Branch 0 taken 10575 times.
✗ Branch 1 not taken.
10575 oldPositions.insert(curpos);
28723
28724 //1. Perform any shifts required by the above
28725 //2. If that's not possible, go to position 1 and reset the b weapon.
28726 //2a. -if we arrive at a position we've already visited, give up and stay there
28727 //3. Get the weapon at the new slot
28728 //4. If it's not possible, go to step 1.
28729
28730 35897 for(;;)
28731 {
28732 //shift
28733
4/5
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 5120 times.
✓ Branch 3 taken 30643 times.
✗ Branch 4 not taken.
35897 switch(type)
28734 {
28735 case SEL_LEFT:
28736 case SEL_VERIFY_LEFT:
28737 5120 curpos = current_subscreen_active->objects[p].d6;
28738 5120 break;
28739
28740 case SEL_RIGHT:
28741 case SEL_VERIFY_RIGHT:
28742 30643 curpos = current_subscreen_active->objects[p].d7;
28743 30643 break;
28744
28745 case SEL_DOWN:
28746 36 curpos = current_subscreen_active->objects[p].d5;
28747 36 break;
28748
28749 case SEL_UP:
28750 98 curpos = current_subscreen_active->objects[p].d4;
28751 98 break;
28752 }
28753
28754 //find our new position
28755 35897 p = -1;
28756
28757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1173149 times.
1173149 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
28758 {
28759
2/2
✓ Branch 0 taken 260361 times.
✓ Branch 1 taken 912788 times.
1173149 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
28760 {
28761
2/2
✓ Branch 0 taken 876891 times.
✓ Branch 1 taken 35897 times.
912788 if(current_subscreen_active->objects[i].d3==curpos)
28762 {
28763 35897 p=i;
28764 35897 break;
28765 }
28766 876891 }
28767 1137252 }
28768
28769
1/2
✓ Branch 0 taken 35897 times.
✗ Branch 1 not taken.
35897 if(p == -1)
28770 {
28771 //can't find the current position
28772 //FAILURE
28773 return failpos;
28774 }
28775
28776 //if we've already been here, give up
28777
3/4
✓ Branch 0 taken 35897 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34221 times.
✓ Branch 3 taken 1676 times.
35897 if(oldPositions.find(curpos) != oldPositions.end())
28778 {
28779 1676 return failpos;
28780 }
28781
28782 //else, remember we've been here
28783
1/2
✓ Branch 0 taken 34221 times.
✗ Branch 1 not taken.
34221 oldPositions.insert(curpos);
28784
28785 //see if this weapon is acceptable
28786
9/10
✓ Branch 0 taken 34221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9128 times.
✓ Branch 3 taken 25093 times.
✓ Branch 4 taken 8917 times.
✓ Branch 5 taken 211 times.
✓ Branch 6 taken 8907 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 8899 times.
34221 if(Bweapon(curpos) != 0 && curpos != forbiddenpos && curpos != fp2 && curpos != fp3)
28787 8899 return curpos;
28788
28789 //keep going otherwise
28790 }
28791 61448 }
28792
28793 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
28794 46138 int32_t selectSword()
28795 {
28796 46138 auto ret = current_item_id(itype_sword);
28797
2/2
✓ Branch 0 taken 1373 times.
✓ Branch 1 taken 44765 times.
46138 if(ret == -1) return 0;
28798 44765 return ret;
28799 46138 }
28800
28801 // Adding code here for allowing hardcoding a button to a specific itemclass.
28802 int32_t selectItemclass(int32_t itemclass)
28803 {
28804 int32_t ret = current_item_id(itemclass);
28805
28806 if(ret == -1)
28807 ret = 0;
28808
28809 return ret;
28810 }
28811
28812 // Used for the 'Pickup Hearts' item pickup condition.
28813 111 bool canget(int32_t id)
28814 {
28815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
28816 }
28817
28818 31 void dospecialmoney(int32_t index)
28819 {
28820 31 int32_t tmp=currscr>=128?1:0;
28821 31 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
28822
28823
4/7
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
31 switch(tmpscr[tmp].room)
28824 {
28825 case rINFO: // pay for info
28826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
28827 {
28828
28829
28830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!current_item_power(itype_wallet))
28831 {
28832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (game->get_spendable_rupies() < abs(prices[priceindex]))
28833 return;
28834 2 int32_t tmpprice = -abs(prices[priceindex]);
28835 2 int32_t total = game->get_drupy()-tmpprice;
28836 2 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28837 2 game->set_drupy(game->get_drupy()-total);
28838 //game->change_drupy(-abs(prices[priceindex]));
28839 2 }
28840
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( current_item_power(itype_wallet)>0 )
28841 {
28842 game->change_drupy(0);
28843 }
28844 2 }
28845 2 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
28846 2 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
28847 2 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
28848 2 clear_bitmap(pricesdisplaybuf);
28849 2 set_clip_state(pricesdisplaybuf, 1);
28850 2 items.del(0);
28851
28852
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for(int32_t i=0; i<items.Count(); i++)
28853 6 ((item*)items.spr(i))->pickup=ipDUMMY;
28854
28855 // Prevent the prices from being displayed anymore
28856
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for(int32_t i=0; i<3; i++)
28857 {
28858 6 prices[i] = 0;
28859 6 }
28860
28861 2 break;
28862
28863 case rMONEY: // secret money
28864 {
28865 14 ((item*)items.spr(0))->pickup = ipDUMMY;
28866
28867 14 prices[0] = tmpscr[tmp].catchall;
28868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (!current_item_power(itype_wallet))
28869 14 game->change_drupy(prices[0]);
28870 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
28871
28872 14 putprices(false);
28873
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28874 14 break;
28875 }
28876
28877 case rGAMBLE: // gamble
28878 {
28879 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
28880
28881 unsigned si=(zc_oldrand()%24)*3;
28882
28883 for(int32_t i=0; i<3; i++)
28884 prices[i]=gambledat[si++];
28885
28886 game->set_drupy(game->get_drupy()+prices[priceindex]);
28887 putprices(true);
28888
28889 for(int32_t i=1; i<4; i++)
28890 ((item*)items.spr(i))->pickup=ipDUMMY;
28891 }
28892 break;
28893
28894 case rBOMBS:
28895 {
28896
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
28897 return;
28898
28899 4 int32_t price = -tmpscr[tmp].catchall;
28900 4 int32_t wmedal = current_item_id(itype_wealthmedal);
28901
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(wmedal >= 0)
28902 {
28903 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
28904 price*=(itemsbuf[wmedal].misc1/100.0);
28905 else
28906 price+=itemsbuf[wmedal].misc1;
28907 }
28908
28909 4 int32_t total = game->get_drupy()-price;
28910 4 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28911 4 game->set_drupy(game->get_drupy()-total);
28912 //game->set_drupy(game->get_drupy()+price);
28913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28914 4 game->change_maxbombs(4);
28915 4 game->set_bombs(game->get_maxbombs());
28916 {
28917 4 int32_t div = zinit.bomb_ratio;
28918
28919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(div > 0)
28920 4 game->change_maxcounter(4/div, 6);
28921 }
28922
28923 //also give Hero an actual Bomb item
28924
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<MAXITEMS; i++)
28925 {
28926
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1018 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
1024 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
28927 4 getitem(i, true, true);
28928 1024 }
28929
28930 4 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
28931 4 fadeclk=66;
28932 4 dismissmsg();
28933 4 clear_bitmap(pricesdisplaybuf);
28934 4 set_clip_state(pricesdisplaybuf, 1);
28935 // putscr(scrollbuf,0,0,tmpscr);
28936 4 verifyBothWeapons();
28937 4 break;
28938 }
28939
28940 case rARROWS:
28941 {
28942 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
28943 return;
28944
28945 int32_t price = -tmpscr[tmp].catchall;
28946 int32_t wmedal = current_item_id(itype_wealthmedal);
28947 if(wmedal >= 0)
28948 {
28949 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
28950 price*=(itemsbuf[wmedal].misc1/100.0);
28951 else
28952 price+=itemsbuf[wmedal].misc1;
28953 }
28954
28955 int32_t total = game->get_drupy()-price;
28956 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28957 game->set_drupy(game->get_drupy()-total);
28958
28959 //game->set_drupy(game->get_drupy()+price);
28960 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28961 game->change_maxarrows(10);
28962 game->set_arrows(game->get_maxarrows());
28963 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
28964 fadeclk=66;
28965 dismissmsg();
28966 clear_bitmap(pricesdisplaybuf);
28967 set_clip_state(pricesdisplaybuf, 1);
28968 // putscr(scrollbuf,0,0,tmpscr);
28969 verifyBothWeapons();
28970 break;
28971 }
28972
28973 case rSWINDLE:
28974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(items.spr(index)->id==iRupy)
28975 {
28976
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
28977 return;
28978 11 int32_t tmpprice = -tmpscr[tmp].catchall;
28979 11 int32_t total = game->get_drupy()-tmpprice;
28980 11 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28981 11 game->set_drupy(game->get_drupy()-total);
28982 11 }
28983 else
28984 {
28985 if(game->get_maxlife()<=game->get_hp_per_heart())
28986 return;
28987
28988 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
28989 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
28990 }
28991
28992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28993 11 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
28994 11 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
28995 11 fadeclk=66;
28996 11 dismissmsg();
28997 11 clear_bitmap(pricesdisplaybuf);
28998 11 set_clip_state(pricesdisplaybuf, 1);
28999 // putscr(scrollbuf,0,0,tmpscr);
29000 11 break;
29001 }
29002 31 }
29003
29004 9600 void getitem(int32_t id, bool nosound, bool doRunPassive)
29005 {
29006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(unsigned(id) >= MAXITEMS)
29007 return;
29008
29009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if (replay_is_active())
29010
1/2
✓ Branch 0 taken 9600 times.
✗ Branch 1 not taken.
9600 replay_step_comment(fmt::format("getitem {}", item_string[id]));
29011
29012
2/2
✓ Branch 0 taken 9590 times.
✓ Branch 1 taken 10 times.
9600 if(get_bit(quest_rules,qr_SCC_ITEM_COMBINES_ITEMS))
29013 {
29014 10 int32_t nextitem = -1;
29015 10 do
29016 {
29017 10 nextitem = -1;
29018
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
29019 // Item upgrade routine.
29020 {
29021
29022 for(int32_t i=0; i<MAXITEMS; i++)
29023 {
29024 // Find the item which is as close to this item's fam_type as possible.
29025 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
29026 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
29027 {
29028 nextitem = i;
29029 }
29030 }
29031
29032 if(nextitem>-1)
29033 {
29034 id = nextitem;
29035 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
29036 break; //no looping
29037 }
29038 }
29039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 } while(nextitem > -1);
29040 10 }
29041
29042 9600 itemdata const& idat = itemsbuf[id&0xFF];
29043
29044 19200 bool equipment = idat.flags &
29045 9600 ((idat.family == itype_triforcepiece) ? ITEM_FLAG8 : ITEM_GAMEDATA);
29046
29047
2/2
✓ Branch 0 taken 8665 times.
✓ Branch 1 taken 935 times.
9600 if(equipment)
29048 {
29049 // Fix boomerang sounds.
29050 935 int32_t itemid = current_item_id(idat.family);
29051
29052
4/6
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 536 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
935 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_divineprotection
29053
5/6
✓ Branch 0 taken 536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 534 times.
✓ Branch 5 taken 1 times.
536 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
29054 548 && sfx_allocated(itemsbuf[itemid].usesound)
29055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 548 times.
548 && idat.usesound != itemsbuf[itemid].usesound)
29056 {
29057 stop_sfx(itemsbuf[itemid].usesound);
29058 cont_sfx(idat.usesound);
29059 }
29060
29061 935 int32_t curitm = current_item_id(idat.family);
29062
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
935 if(!get_bit(quest_rules,qr_KEEPOLD_APPLIES_RETROACTIVELY)
29063
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
935 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
29064 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
29065 {
29066 935 game->set_item(id,true);
29067 935 passiveitem_script(id, doRunPassive);
29068 935 }
29069
29070
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 627 times.
935 if(!(idat.flags & ITEM_KEEPOLD))
29071 {
29072
3/4
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 513 times.
627 if(!get_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
29073 {
29074 114 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
29075 114 }
29076 627 }
29077
29078 // NES consistency: replace all flying boomerangs with the current boomerang.
29079
2/2
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 29 times.
935 if(idat.family==itype_brang)
29080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 for(int32_t i=0; i<Lwpns.Count(); i++)
29081 {
29082 weapon *w = ((weapon*)Lwpns.spr(i));
29083
29084 if(w->id==wBrang)
29085 {
29086 w->LOADGFX(idat.wpn);
29087 }
29088 29 }
29089 935 }
29090
29091
2/2
✓ Branch 0 taken 1574 times.
✓ Branch 1 taken 8026 times.
9600 if(idat.count!=-1)
29092 {
29093
2/2
✓ Branch 0 taken 7816 times.
✓ Branch 1 taken 210 times.
8026 if(idat.setmax)
29094 {
29095 // Bomb bags are a special case; they may be set not to increase super bombs
29096
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 203 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
210 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
29097 {
29098 int32_t max = game->get_maxbombs();
29099
29100 if(max<idat.max) max=idat.max;
29101
29102 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
29103 }
29104 else
29105 {
29106 210 int32_t max = game->get_maxcounter(idat.count);
29107
29108
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 177 times.
210 if(max<idat.max) max=idat.max;
29109
29110
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 61 times.
210 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
29111 }
29112 210 }
29113
29114 // Amount is an uint16_t, but the range is -9999 to 16383
29115 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
29116
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 7829 times.
8026 if(idat.amount&0x3FFF)
29117 {
29118
2/2
✓ Branch 0 taken 5023 times.
✓ Branch 1 taken 2806 times.
7829 if(idat.amount&0x8000)
29119 10046 game->set_dcounter(
29120
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5022 times.
5023 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29121 else
29122 {
29123
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2806 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2806 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
29124 game->set_counter(0, idat.count);
29125 else
29126 // This is too confusing to try and change...
29127
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2806 times.
✓ Branch 2 taken 1284 times.
✓ Branch 3 taken 1522 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1284 times.
2806 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
29128 }
29129 7829 }
29130 8026 }
29131
29132
4/4
✓ Branch 0 taken 9597 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 231 times.
✓ Branch 3 taken 9366 times.
9600 if(idat.playsound&&!nosound)
29133 {
29134 9366 sfx(idat.playsound);
29135 9366 }
29136
29137 //add lower-level items
29138
2/2
✓ Branch 0 taken 9572 times.
✓ Branch 1 taken 28 times.
9600 if(idat.flags&ITEM_GAINOLD)
29139 {
29140
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 28 times.
52 for(int32_t i=idat.fam_type-1; i>0; i--)
29141 {
29142 24 int32_t potid = getItemID(itemsbuf, idat.family, i);
29143
29144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(potid != -1)
29145 {
29146 24 game->set_item(potid, true);
29147 24 }
29148 24 }
29149 28 }
29150
29151
11/14
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 8612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 385 times.
✓ Branch 6 taken 41 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 57 times.
✓ Branch 9 taken 53 times.
✓ Branch 10 taken 27 times.
✓ Branch 11 taken 356 times.
✓ Branch 12 taken 35 times.
✓ Branch 13 taken 5 times.
9600 switch(idat.family)
29152 {
29153 case itype_itmbundle:
29154 {
29155 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
29156 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
29157 bool pscript = (idat.flags & ITEM_FLAG1);
29158 for(auto q = 0; q < 10; ++q)
29159 {
29160 if(unsigned(ids[q]) >= MAXITEMS) continue;
29161 if(pscript)
29162 collectitem_script(ids[q]);
29163 getitem(ids[q], true, true);
29164 }
29165 }
29166 break;
29167
29168 case itype_progressive_itm:
29169 {
29170 int32_t newid = get_progressive_item(idat);
29171 if(newid > -1)
29172 getitem(newid, nosound, true);
29173 }
29174 break;
29175
29176 case itype_bottlefill:
29177 {
29178 if(idat.misc1)
29179 {
29180 game->fillBottle(idat.misc1);
29181 }
29182 }
29183 break;
29184
29185 case itype_clock:
29186 {
29187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
385 if(idat.flags & ITEM_FLAG1) //Active use, not passive
29188 break;
29189
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
29190 break;
29191 385 setClock(watch=true);
29192
29193
2/2
✓ Branch 0 taken 197120 times.
✓ Branch 1 taken 385 times.
197505 for(int32_t i=0; i<eMAXGUYS; i++)
29194 197120 clock_zoras[i]=0;
29195
29196 385 clockclk=itemsbuf[id&0xFF].misc1;
29197 385 sfx(idat.usesound);
29198 }
29199 385 break;
29200
29201 case itype_lkey:
29202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
29203 41 break;
29204
29205 case itype_ring:
29206 case itype_magicring:
29207
6/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 1 times.
25 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
29208 {
29209 24 ringcolor(false);
29210 24 }
29211 25 break;
29212
29213 case itype_whispring:
29214 {
29215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(idat.flags & ITEM_FLAG1)
29216 {
29217
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
29218
29219
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
29220 4 }
29221
29222
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(idat.power==0)
29223 {
29224 2 setSwordClk(0);
29225 2 setItemClk(0);
29226 2 }
29227
29228 4 break;
29229 }
29230
29231
29232 case itype_map:
29233 57 game->lvlitems[dlevel]|=liMAP;
29234 57 break;
29235
29236 case itype_compass:
29237 53 game->lvlitems[dlevel]|=liCOMPASS;
29238 53 break;
29239
29240 case itype_bosskey:
29241 27 game->lvlitems[dlevel]|=liBOSSKEY;
29242 27 break;
29243
29244 case itype_fairy:
29245
29246
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✓ Branch 2 taken 119 times.
✓ Branch 3 taken 237 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 119 times.
356 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
29247
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 302 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 54 times.
356 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
29248 356 break;
29249
29250 case itype_heartpiece:
29251 35 game->change_HCpieces(1);
29252
29253
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
35 if(game->get_HCpieces()<game->get_hcp_per_hc())
29254 28 break;
29255
29256 7 game->set_HCpieces(0);
29257
29258 7 getitem(heart_container_id());
29259 7 break;
29260
29261 case itype_killem:
29262 {
29263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(idat.flags & ITEM_FLAG1) //Active use, not passive
29264 break;
29265 5 kill_em_all();
29266 5 sfx(idat.usesound);
29267 }
29268 5 break;
29269 }
29270
29271 9600 flushItemCache();
29272 9600 update_subscreens();
29273 9600 load_Sitems(&QMisc);
29274 9600 verifyBothWeapons();
29275 9600 }
29276
29277 void takeitem(int32_t id)
29278 {
29279 game->set_item(id, false);
29280 itemdata const& idat = itemsbuf[id];
29281
29282 /* Lower the counters! */
29283 if(idat.count!=-1)
29284 {
29285 if(idat.setmax)
29286 {
29287 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
29288 }
29289
29290 if(idat.amount&0x3FFF)
29291 {
29292 if(idat.amount&0x8000)
29293 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29294 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29295 }
29296 }
29297
29298 switch(itemsbuf[id&0xFF].family)
29299 {
29300 // NES consistency: replace all flying boomerangs with the current boomerang.
29301 case itype_brang:
29302 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
29303 {
29304 weapon *w = ((weapon*)Lwpns.spr(i));
29305
29306 if(w->id==wBrang)
29307 {
29308 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
29309 }
29310 }
29311
29312 break;
29313
29314 case itype_itmbundle:
29315 {
29316 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
29317 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
29318 for(auto q = 0; q < 10; ++q)
29319 {
29320 if(unsigned(ids[q]) >= MAXITEMS) continue;
29321 takeitem(ids[q]);
29322 }
29323 }
29324 break;
29325
29326 case itype_progressive_itm:
29327 {
29328 int32_t newid = get_progressive_item(idat, true);
29329 if(newid > -1)
29330 takeitem(newid);
29331 }
29332 break;
29333
29334 case itype_heartpiece:
29335 if(game->get_maxlife()>game->get_hp_per_heart())
29336 {
29337 if(game->get_HCpieces()==0)
29338 {
29339 game->set_HCpieces(game->get_hcp_per_hc());
29340 takeitem(iHeartC);
29341 }
29342
29343 game->change_HCpieces(-1);
29344 }
29345 break;
29346
29347 case itype_map:
29348 game->lvlitems[dlevel]&=~liMAP;
29349 break;
29350
29351 case itype_compass:
29352 game->lvlitems[dlevel]&=~liCOMPASS;
29353 break;
29354
29355 case itype_bosskey:
29356 game->lvlitems[dlevel]&=~liBOSSKEY;
29357 break;
29358
29359 case itype_lkey:
29360 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
29361 break;
29362
29363 case itype_ring:
29364 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
29365 {
29366 ringcolor(false);
29367 }
29368 break;
29369 }
29370 }
29371
29372 6931 void post_item_collect()
29373 {
29374 6931 std::vector<int32_t> &ev = FFCore.eventData;
29375 6931 ev.clear();
29376
29377 6931 throwGenScriptEvent(GENSCR_EVENT_POST_COLLECT_ITEM);
29378 6931 }
29379
29380 6981 void HeroClass::handle_triforce(int32_t id)
29381 {
29382
1/2
✓ Branch 0 taken 6981 times.
✗ Branch 1 not taken.
6981 if(unsigned(id) >= MAXITEMS)
29383 return;
29384 6981 itemdata const& itm = itemsbuf[id];
29385
2/3
✓ Branch 0 taken 6914 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
6981 switch(itm.family)
29386 {
29387 case itype_itmbundle:
29388 {
29389 int ids[10] = {itm.misc1, itm.misc2, itm.misc3, itm.misc4, itm.misc5,
29390 itm.misc6, itm.misc7, itm.misc8, itm.misc9, itm.misc10};
29391 for(auto q = 0; q < 10; ++q)
29392 {
29393 if(unsigned(ids[q]) >= MAXITEMS) continue;
29394 handle_triforce(ids[q]);
29395 }
29396 }
29397 break;
29398 case itype_triforcepiece:
29399 {
29400
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 60 times.
67 if(itm.misc2>0)
29401 60 getTriforce(id); //small
29402 7 else getBigTri(id); //big
29403 }
29404 67 break;
29405 }
29406 6981 }
29407
29408 // Attempt to pick up an item. (-1 = check items touching Hero.)
29409 6397336 void HeroClass::checkitems(int32_t index)
29410 {
29411 6397336 int32_t tmp=currscr>=128?1:0;
29412
29413
2/2
✓ Branch 0 taken 1451 times.
✓ Branch 1 taken 6395885 times.
6397336 if(index==-1)
29414 {
29415
2/2
✓ Branch 0 taken 1309839 times.
✓ Branch 1 taken 6395885 times.
7705724 for(auto ind = items.Count()-1; ind >= 0; --ind)
29416 {
29417 1309839 item* itm = (item*)items.spr(ind);
29418
2/2
✓ Branch 0 taken 1309827 times.
✓ Branch 1 taken 12 times.
1309839 if(itm->get_forcegrab())
29419 {
29420 12 checkitems(ind);
29421 12 }
29422 1309839 }
29423
2/2
✓ Branch 0 taken 700080 times.
✓ Branch 1 taken 5695805 times.
6395885 if(diagonalMovement)
29424 {
29425 700080 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
29426 700080 }
29427 5695805 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
29428 6395885 }
29429
29430
2/2
✓ Branch 0 taken 50803 times.
✓ Branch 1 taken 6346533 times.
6397336 if(index==-1)
29431 6346533 return;
29432
29433 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
29434 // return;
29435 50803 item* ptr = (item*)items.spr(index);
29436 50803 int32_t pickup = ptr->pickup;
29437 50803 int8_t exstate = ptr->pickupexstate;
29438 50803 int32_t PriceIndex = ptr->PriceIndex;
29439 50803 int32_t id2 = ptr->id;
29440 50803 int32_t holdid = ptr->id;
29441 50803 int32_t pstr = ptr->pstring;
29442 50803 int32_t pstr_flags = ptr->pickup_string_flags;
29443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50803 times.
50803 if(ptr->fallclk > 0) return; //Don't pick up a falling item
29444
29445
1/2
✓ Branch 0 taken 50803 times.
✗ Branch 1 not taken.
50803 if(itemsbuf[id2].family == itype_progressive_itm)
29446 {
29447 int32_t newid = get_progressive_item(itemsbuf[id2]);
29448 if(newid > -1)
29449 {
29450 id2 = newid;
29451 holdid = newid;
29452 pstr = itemsbuf[newid].pstring;
29453 pstr_flags = itemsbuf[newid].pickup_string_flags;
29454 }
29455 }
29456
29457
2/2
✓ Branch 0 taken 49937 times.
✓ Branch 1 taken 866 times.
50803 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
29458
29459
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50801 times.
50803 if(bottledummy) //Dummy bullshit!
29460 {
29461
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!game->canFillBottle())
29462 return;
29463
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
29464 {
29465 if(!current_item_power(itype_wallet))
29466 {
29467 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
29468 int32_t tmpprice = -abs(prices[PriceIndex]);
29469 //game->change_drupy(-abs(prices[priceindex]));
29470 int32_t total = game->get_drupy()-tmpprice;
29471 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29472 game->set_drupy(game->get_drupy()-total);
29473 }
29474 else //infinite wallet
29475 {
29476 game->change_drupy(0);
29477 }
29478 }
29479 2 boughtsomething=true;
29480 //make the other shop items untouchable after
29481 //you buy something
29482 2 int32_t count = 0;
29483
29484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<3; i++)
29485 {
29486 if(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[i] != 0)
29487 {
29488 ++count;
29489 }
29490 }
29491
29492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<items.Count(); i++)
29493 {
29494 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
29495 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
29496 }
29497
29498 2 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
29499 2 id2 = find_bottle_for_slot(slot);
29500 2 ptr->id = id2;
29501 2 pstr = 0;
29502 2 pickup |= ipHOLDUP;
29503 2 }
29504 else
29505 {
29506 50801 std::vector<int32_t> &ev = FFCore.eventData;
29507 50801 ev.clear();
29508 50801 ev.push_back(id2*10000);
29509 50801 ev.push_back(pickup*10000);
29510 50801 ev.push_back(pstr*10000);
29511 50801 ev.push_back(pstr_flags*10000);
29512 50801 ev.push_back(0);
29513 50801 ev.push_back(ptr->getUID());
29514 50801 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
29515 50801 ev.push_back(0);
29516
29517 50801 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
29518 50801 bool nullify = ev[4] != 0;
29519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50801 times.
50801 if(nullify) return;
29520 50801 id2 = ev[0]/10000;
29521 50801 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
29522 50801 pstr = ev[2] / 10000;
29523 50801 pstr_flags = ev[3] / 10000;
29524
29525
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50801 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50801 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
29526 return; //No picking these up unless you have a bottle to fill!
29527
29528
5/6
✓ Branch 0 taken 48416 times.
✓ Branch 1 taken 2385 times.
✓ Branch 2 taken 42740 times.
✓ Branch 3 taken 5676 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 42740 times.
50801 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
29529
2/2
✓ Branch 0 taken 42620 times.
✓ Branch 1 taken 120 times.
42740 if(ptr->id!=iFairyMoving)
29530 // wait for it to stop flashing, doesn't check for other items yet
29531 42620 return;
29532
29533
2/2
✓ Branch 0 taken 8154 times.
✓ Branch 1 taken 27 times.
8181 if(pickup&ipENEMY) // item was being carried by enemy
29534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
54 if(more_carried_items()<=1) // 1 includes this own item.
29535 27 hasitem &= ~2;
29536
29537
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 7693 times.
8181 if(pickup&ipDUMMY) // dummy item (usually a rupee)
29538 {
29539
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 31 times.
488 if(pickup&ipMONEY)
29540 31 dospecialmoney(index);
29541
29542 488 return;
29543 }
29544
29545
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7693 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7693 if(get_bit(quest_rules,qr_HEARTSREQUIREDFIX) && !canget(id2))
29546 return;
29547
29548 7693 int32_t nextitem = -1;
29549 7693 do
29550 {
29551 7693 nextitem = -1;
29552
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 7679 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 10 times.
7693 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
29553 // Item upgrade routine.
29554 {
29555
29556
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 10 times.
2570 for(int32_t i=0; i<MAXITEMS; i++)
29557 {
29558 // Find the item which is as close to this item's fam_type as possible.
29559
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2538 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 10 times.
2560 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
29560
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
22 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
29561 {
29562 10 nextitem = i;
29563 10 }
29564 2560 }
29565
29566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nextitem>-1)
29567 {
29568 10 id2 = nextitem;
29569
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(get_bit(quest_rules,qr_ITEMCOMBINE_NEW_PSTR))
29570 {
29571 pstr = itemsbuf[id2].pstring;
29572 pstr_flags = itemsbuf[id2].pickup_string_flags;
29573 }
29574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
29575 10 break; //no looping
29576 }
29577 }
29578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7683 times.
7683 } while(nextitem > -1);
29579
29580
2/2
✓ Branch 0 taken 6827 times.
✓ Branch 1 taken 866 times.
7693 if(pickup&ipCHECK) // check restrictions
29581
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 648 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 107 times.
866 switch(tmpscr[tmp].room)
29582 {
29583 case rSP_ITEM: // special item
29584
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 19 times.
111 if(!canget(id2)) // These ones always need the Hearts Required check
29585 19 return;
29586
29587 92 break;
29588
29589 case rP_SHOP: // potion shop
29590
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 14 times.
107 if(msg_active)
29591 93 return;
29592 [[fallthrough]];
29593 case rSHOP: // shop
29594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662 times.
662 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
29595 {
29596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662 times.
662 if(!current_item_power(itype_wallet))
29597 {
29598
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 62 times.
662 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
29599 62 int32_t tmpprice = -abs(prices[PriceIndex]);
29600 //game->change_drupy(-abs(prices[priceindex]));
29601 62 int32_t total = game->get_drupy()-tmpprice;
29602 62 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29603 62 game->set_drupy(game->get_drupy()-total);
29604 62 }
29605 else //infinite wallet
29606 {
29607 game->change_drupy(0);
29608 }
29609 62 }
29610 62 boughtsomething=true;
29611 //make the other shop items untouchable after
29612 //you buy something
29613 62 int32_t count = 0;
29614
29615
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 62 times.
248 for(int32_t i=0; i<3; i++)
29616 {
29617
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 177 times.
186 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
29618 {
29619 177 ++count;
29620 177 }
29621 186 }
29622
29623
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 62 times.
301 for(int32_t i=0; i<items.Count(); i++)
29624 {
29625
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 115 times.
239 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
29626 115 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
29627 239 }
29628
29629 62 break;
29630 154 }
29631
29632
2/2
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 6208 times.
6981 if(pickup&ipONETIME) // set mITEM for one-time-only items
29633 {
29634 773 setmapflag(mITEM);
29635
29636 //Okay so having old source files is a godsend. You wanna know why?
29637 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
29638 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
29639 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
29640 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
29641 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
29642
29643 /*
29644 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
29645 // broken behavior from early ZC versions. If you change things here please comment on it's purpose.
29646
29647 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
29648 // What is etc?! We need to check for every valid state here. ~Gleeok
29649 if(get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW))
29650 {
29651 // Most older quests need one-time-pickups to not remove special items, etc.
29652 if(tmpscr->room==rGRUMBLE)
29653 {
29654 setmapflag(mSPECIALITEM);
29655 }
29656 }
29657 */
29658 773 }
29659
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 264 times.
6208 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
29660
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 74 times.
264 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29661
29662
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6980 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
6981 if(exstate > -1 && exstate < 32)
29663 {
29664 1 setxmapflag(1<<exstate);
29665 1 }
29666
29667
2/2
✓ Branch 0 taken 6980 times.
✓ Branch 1 taken 1 times.
6981 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
29668 {
29669
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
29670 1 hidden_entrance(0, true, false, -5);
29671 1 }
29672
29673 6981 collectitem_script(id2);
29674 6981 getitem(id2, false, true);
29675 }
29676
29677
2/2
✓ Branch 0 taken 538 times.
✓ Branch 1 taken 6441 times.
6983 if(pickup&ipHOLDUP)
29678 {
29679 538 attackclk=0;
29680 538 reset_swordcharge();
29681
29682
3/4
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 534 times.
538 if(action!=swimming && !IsSideSwim())
29683 534 reset_hookshot();
29684
29685
2/2
✓ Branch 0 taken 373 times.
✓ Branch 1 taken 165 times.
538 if(msg_onscreen)
29686 {
29687 165 dismissmsg();
29688 165 }
29689
29690 538 clear_bitmap(pricesdisplaybuf);
29691
29692
6/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
539 if(get_bit(quest_rules, qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
29693
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 (get_bit(quest_rules, qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
29694 {
29695 539 fadeclk=66;
29696 539 }
29697
29698
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 538 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
540 if(id2!=iBombs || action==swimming || get_bit(quest_rules,qr_BOMBHOLDFIX))
29699 {
29700 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
29701
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 532 times.
538 if(action==swimming)
29702 {
29703 6 action=waterhold1; FFCore.setHeroAction(waterhold1);
29704 6 }
29705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 else if(IsSideSwim())
29706 {
29707 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
29708 }
29709 else
29710 {
29711 532 action=landhold1; FFCore.setHeroAction(landhold1);
29712 }
29713
29714
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 176 times.
538 if(ptr->twohand)
29715 {
29716
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 175 times.
176 if(action==waterhold1)
29717 {
29718 1 action=waterhold2; FFCore.setHeroAction(waterhold2);
29719 1 }
29720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175 times.
175 else if(action==sidewaterhold1)
29721 {
29722 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
29723 }
29724 else
29725 {
29726 175 action=landhold2; FFCore.setHeroAction(landhold2);
29727 }
29728 176 }
29729
29730 538 holdclk=130;
29731
29732 //restart music
29733
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 77 times.
538 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0)
29734 77 music_stop();
29735
29736 538 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
29737 538 freeze_guys=true;
29738 //show the info string
29739
29740
29741 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
29742
29743 538 int32_t shop_pstr = 0;
29744
2/2
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 75 times.
538 if (PriceIndex > -1)
29745 {
29746
2/3
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
75 switch(tmpscr[tmp].room)
29747 {
29748 case rSHOP:
29749 48 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
29750 48 break;
29751 case rBOTTLESHOP:
29752 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
29753 break;
29754 }
29755 75 }
29756
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 538 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 538 times.
538 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
29757 {
29758 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
29759 {
29760 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
29761 }
29762 else pstr = 0;
29763 if(shop_pstr)
29764 {
29765 donewmsg(shop_pstr);
29766 enqueued_str = pstr;
29767 }
29768 else if(pstr)
29769 {
29770 donewmsg(pstr);
29771 }
29772 }
29773
29774 538 }
29775
29776
3/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
540 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
29777 {
29778 480 sfx(tmpscr[0].holdupsfx);
29779 480 }
29780
29781 540 ptr->set_forcegrab(false);
29782 540 items.del(index);
29783
29784
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 540 times.
663 for(int32_t i=0; i<Lwpns.Count(); i++)
29785 {
29786 123 weapon *w = (weapon*)Lwpns.spr(i);
29787
29788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(w->dragging==index)
29789 {
29790 w->dragging=-1;
29791 }
29792
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 else if(w->dragging>index)
29793 {
29794 w->dragging-=1;
29795 }
29796 123 }
29797
29798 // clear up shop stuff
29799
4/4
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 272 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 73 times.
540 if((isdungeon()==0)&&(index!=0))
29800 {
29801
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 57 times.
73 if(boughtsomething)
29802 {
29803 57 fadeclk=66;
29804
29805
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
57 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
29806 {
29807 57 items.del(0);
29808
29809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 for(int32_t i=0; i<Lwpns.Count(); i++)
29810 {
29811 weapon *w = (weapon*)Lwpns.spr(i);
29812
29813 if(w->dragging==0)
29814 {
29815 w->dragging=-1;
29816 }
29817 else if(w->dragging>0)
29818 {
29819 w->dragging-=1;
29820 }
29821 }
29822 57 }
29823 57 }
29824
29825
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(msg_onscreen)
29826 {
29827 dismissmsg();
29828 }
29829
29830 73 clear_bitmap(pricesdisplaybuf);
29831 73 set_clip_state(pricesdisplaybuf, 1);
29832 73 }
29833
29834 // items.del(index);
29835 540 }
29836 else
29837 {
29838 6441 ptr->set_forcegrab(false);
29839 6441 items.del(index);
29840
29841
2/2
✓ Branch 0 taken 5457 times.
✓ Branch 1 taken 6441 times.
11898 for(int32_t i=0; i<Lwpns.Count(); i++)
29842 {
29843 5457 weapon *w = (weapon*)Lwpns.spr(i);
29844
29845
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 5420 times.
5457 if(w->dragging==index)
29846 {
29847 37 w->dragging=-1;
29848 37 }
29849
1/2
✓ Branch 0 taken 5420 times.
✗ Branch 1 not taken.
5420 else if(w->dragging>index)
29850 {
29851 w->dragging-=1;
29852 }
29853 5457 }
29854
29855
2/2
✓ Branch 0 taken 6432 times.
✓ Branch 1 taken 9 times.
6441 if(msg_onscreen)
29856 {
29857 9 dismissmsg();
29858 9 }
29859
29860 //general item pickup message
29861 //show the info string
29862 //non-held
29863 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
29864
3/6
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 6309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6441 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
29865
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6440 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6440 times.
6441 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
29866 {
29867
6/12
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
1 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
29868 {
29869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
29870 1 }
29871 else pstr = 0;
29872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(shop_pstr)
29873 {
29874 donewmsg(shop_pstr);
29875 enqueued_str = pstr;
29876 }
29877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(pstr)
29878 {
29879 1 donewmsg(pstr);
29880 1 }
29881 1 }
29882
29883
29884 6441 clear_bitmap(pricesdisplaybuf);
29885 6441 set_clip_state(pricesdisplaybuf, 1);
29886 }
29887
29888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
6988 if(itemsbuf[id2].family==itype_triforcepiece
29889
4/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 6914 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 60 times.
6981 && itemsbuf[id2].misc2 <= 0 && ptr->linked_parent == eeGANON)
29890 {
29891 7 game->lvlitems[dlevel]|=liBOSS;
29892 7 }
29893 6981 handle_triforce(id2);
29894
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 6503 times.
6981 if(!holdclk)
29895 6503 post_item_collect();
29896 6397334 }
29897
29898 186 void HeroClass::StartRefill(int32_t refillWhat)
29899 {
29900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186 times.
186 if(!refilling)
29901 {
29902 186 refillclk=21;
29903 186 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
29904 186 sfx(WAV_REFILL,128,true);
29905 186 refilling=refillWhat;
29906
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 6 times.
186 if(FFCore.quest_format[vZelda] < 0x255)
29907 {
29908 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
29909 //I attempted to change this check to a quest rule, but here's the issue: this affects
29910 //triforces and potions as well, not just fairy flags. This means that having a compat rule
29911 //would result in a rule that is checked by default for every tileset or quest made before
29912 //2.55, one in a place most people won't check. That means that if they were to go to use
29913 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
29914 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
29915 //"go through the compat rules and turn them all off", so this remains a version check instead
29916 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
29917 180 Start250Refill(refillWhat);
29918 180 }
29919 else //use 2.55+ behavior
29920 {
29921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(refill_why>=0) // Item index
29922 {
29923 if(itemsbuf[refill_why].family==itype_potion)
29924 {
29925 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
29926 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
29927 }
29928 else if(itemsbuf[refill_why].family==itype_triforcepiece)
29929 {
29930 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
29931 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
29932 }
29933 }
29934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(refill_why==REFILL_FAIRY)
29935 {
29936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
29937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_bit(quest_rules,qr_ITEMBUBBLE))itemclk=0;
29938 6 }
29939 }
29940 186 }
29941 186 }
29942
29943 180 void HeroClass::Start250Refill(int32_t refillWhat)
29944 {
29945
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!refilling)
29946 {
29947 refillclk=21;
29948 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
29949 sfx(WAV_REFILL,128,true);
29950 refilling=refillWhat;
29951
29952 if(refill_why>=0) // Item index
29953 {
29954 if((itemsbuf[refill_why].family==itype_potion)&&(!get_bit(quest_rules,qr_NONBUBBLEMEDICINE)))
29955 {
29956 swordclk=0;
29957 verifyAWpn();
29958 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
29959 }
29960
29961 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_bit(quest_rules,qr_NONBUBBLETRIFORCE)))
29962 {
29963 swordclk=0;
29964 verifyAWpn();
29965 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
29966 }
29967 }
29968 else if((refill_why==REFILL_FAIRY)&&(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)))
29969 {
29970 swordclk=0;
29971 verifyAWpn();
29972 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
29973 }
29974 }
29975 180 }
29976
29977 223990 bool HeroClass::refill()
29978 {
29979
4/4
✓ Branch 0 taken 17074 times.
✓ Branch 1 taken 206916 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 16438 times.
223990 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
29980 {
29981 207552 return false;
29982 }
29983
29984 16438 ++refillclk;
29985 16438 int32_t speed = get_bit(quest_rules,qr_FASTFILL) ? 6 : 22;
29986 16438 int32_t refill_heart_stop=game->get_maxlife();
29987 16438 int32_t refill_magic_stop=game->get_maxmagic();
29988
29989
4/4
✓ Branch 0 taken 8317 times.
✓ Branch 1 taken 8121 times.
✓ Branch 2 taken 3362 times.
✓ Branch 3 taken 4955 times.
16438 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
29990 {
29991
2/6
✓ Branch 0 taken 4955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4955 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4955 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
29992
2/6
✓ Branch 0 taken 4955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4955 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4955 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
29993 4955 }
29994
29995
2/2
✓ Branch 0 taken 14731 times.
✓ Branch 1 taken 1707 times.
16438 if(refillclk%speed == 0)
29996 {
29997 // game->life&=0xFFC;
29998
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 852 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 855 times.
1707 switch(refill_what)
29999 {
30000 case REFILL_LIFE:
30001
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 813 times.
852 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
30002
30003
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 749 times.
852 if(game->get_life()>=refill_heart_stop)
30004 {
30005 103 game->set_life(refill_heart_stop);
30006 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30007
2/2
✓ Branch 0 taken 26368 times.
✓ Branch 1 taken 103 times.
26471 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30008 {
30009
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 26265 times.
26368 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30010
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26264 times.
26265 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30011 26264 stop_sfx(q);
30012 26264 }
30013 103 sfx(QMisc.miscsfx[sfxREFILL]);
30014 103 refilling=REFILL_NONE;
30015 103 return false;
30016 }
30017
30018 749 break;
30019
30020 case REFILL_MAGIC:
30021 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
30022
30023 if(game->get_magic()>=refill_magic_stop)
30024 {
30025 game->set_magic(refill_magic_stop);
30026 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30027 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30028 {
30029 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30030 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30031 stop_sfx(q);
30032 }
30033 sfx(QMisc.miscsfx[sfxREFILL]);
30034 refilling=REFILL_NONE;
30035 return false;
30036 }
30037
30038 break;
30039
30040 case REFILL_ALL:
30041
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 788 times.
855 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
30042
2/2
✓ Branch 0 taken 825 times.
✓ Branch 1 taken 30 times.
855 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
30043
30044
4/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 753 times.
✓ Branch 2 taken 83 times.
✓ Branch 3 taken 19 times.
855 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
30045 {
30046 83 game->set_life(refill_heart_stop);
30047 83 game->set_magic(refill_magic_stop);
30048 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30049
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 83 times.
21331 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30050 {
30051
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 21165 times.
21248 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30052
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 21146 times.
21165 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30053 21146 stop_sfx(q);
30054 21146 }
30055 83 sfx(QMisc.miscsfx[sfxREFILL]);
30056 83 refilling=REFILL_NONE;
30057 83 return false;
30058 }
30059
30060 772 break;
30061 }
30062 1521 }
30063
30064 16252 return true;
30065 223990 }
30066
30067 60 void HeroClass::getTriforce(int32_t id2)
30068 {
30069
30070 PALETTE flash_pal;
30071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
30072
30073
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 60 times.
15420 for(int32_t i=0; i<256; i++)
30074 {
30075
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 7168 times.
15360 flash_pal[i] = get_bit(quest_rules,qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
30076 15360 }
30077
30078
30079
30080 //get rid off all sprites but Hero
30081 60 guys.clear();
30082 60 items.clear();
30083 60 Ewpns.clear();
30084 60 Lwpns.clear();
30085 60 Sitems.clear();
30086 60 chainlinks.clear();
30087
30088 //decorations.clear();
30089
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 17 times.
60 if(!COOLSCROLL)
30090 {
30091 17 show_subscreen_items=false;
30092 17 }
30093
30094 60 sfx(itemsbuf[id2].playsound);
30095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
30096
30097 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
30098
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
30099 {
30100 uint8_t playwav = itemsbuf[id2].misc3;
30101 //zprint2("playwav is: %d\n", playwav);
30102 sfx(playwav);
30103
30104 }
30105
30106 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
30107 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
30108 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
30109 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
30110 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
30111 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
30112 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
30113
30114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
30115 {
30116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(itemsbuf[id2].misc1)
30117 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
30118 else
30119 60 try_zcmusic((char*)moduledata.base_NSF_file,moduledata.tf_track, ZC_MIDI_TRIFORCE);
30120 60 }
30121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
30122 {
30123 60 game->lvlitems[dlevel]|=liTRIFORCE;
30124 60 }
30125
30126 60 int32_t f=0;
30127 60 int32_t x2=0;
30128 60 int32_t curtain_x=0;
30129 60 int32_t c=0;
30130
30131 60 do
30132 {
30133
30134
30135
1/2
✓ Branch 0 taken 32050 times.
✗ Branch 1 not taken.
32050 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
30136 {
30137 if ( itemsbuf[id2].script )
30138 {
30139 if ( !FFCore.doscript(ScriptType::Item, id2) )
30140 {
30141 int i = id2;
30142 FFCore.reset_script_engine_data(ScriptType::Item, i);
30143 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, i);
30144 FFCore.deallocateAllArrays(ScriptType::Item, i);
30145 }
30146 else
30147 {
30148 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
30149 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
30150 }
30151 }
30152 }
30153 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
30154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
30155 {
30156 return;
30157 }
30158
2/2
✓ Branch 0 taken 31990 times.
✓ Branch 1 taken 60 times.
32050 if(f==40)
30159 {
30160 60 actiontype oldaction = action;
30161 60 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
30162 60 action=oldaction; // have to reset this flag
30163 60 FFCore.setHeroAction(oldaction);
30164 60 }
30165
30166
30167
4/4
✓ Branch 0 taken 29650 times.
✓ Branch 1 taken 2400 times.
✓ Branch 2 taken 26770 times.
✓ Branch 3 taken 2880 times.
32050 if(f>=40 && f<88)
30168 {
30169
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 1344 times.
2880 if(get_bit(quest_rules,qr_FADE))
30170 {
30171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1536 if (!flash_reduction_enabled() && (f&7) == 0)
30172 {
30173 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
30174 refreshpal=true;
30175 }
30176
30177
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 384 times.
1536 if((f&3)==2)
30178 {
30179 384 loadpalset(0,0);
30180 384 loadpalset(1,1);
30181 384 loadpalset(5,5);
30182
30183
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 12 times.
384 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
30184 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
30185 384 }
30186 1536 }
30187 else
30188 {
30189
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1344 if(!flash_reduction_enabled() && (f&7) == 0)
30190 {
30191 for(int32_t cs2=2; cs2<5; cs2++)
30192 {
30193 for(int32_t i=1; i<16; i++)
30194 {
30195 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
30196 }
30197 }
30198
30199 refreshpal=true;
30200 }
30201
30202
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==4)
30203 {
30204
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
30205 else loadlvlpal(0xB);
30206
30207 168 loadpalset(5,5);
30208 168 }
30209 }
30210 2880 }
30211
30212
30213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
30214 {
30215
2/2
✓ Branch 0 taken 31990 times.
✓ Branch 1 taken 60 times.
32050 if(f==refill_frame)
30216 {
30217 60 refill_what=REFILL_ALL;
30218 60 refill_why=id2;
30219 60 StartRefill(REFILL_ALL);
30220 60 refill();
30221 60 }
30222
30223
2/2
✓ Branch 0 taken 28740 times.
✓ Branch 1 taken 3310 times.
32050 if(f==(refill_frame+1))
30224 {
30225
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 3250 times.
3310 if(refill())
30226 {
30227 3250 --f;
30228 3250 }
30229 3310 }
30230 32050 }
30231
30232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
30233 {
30234
4/4
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 15730 times.
✓ Branch 2 taken 11520 times.
✓ Branch 3 taken 4800 times.
32050 if(f>=208 && f<288)
30235 {
30236 4800 ++x2;
30237
30238
3/3
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 1920 times.
✓ Branch 2 taken 960 times.
4800 switch(++c)
30239 {
30240 case 5:
30241 960 c=0;
30242 [[fallthrough]];
30243 case 0:
30244 case 2:
30245 case 3:
30246 2880 ++x2;
30247 2880 break;
30248 }
30249 4800 }
30250
30251 32050 do_dcounters();
30252
30253
2/2
✓ Branch 0 taken 11520 times.
✓ Branch 1 taken 20530 times.
32050 if(f<288)
30254 {
30255 20530 curtain_x=x2&0xF8;
30256 20530 draw_screen_clip_rect_x1=curtain_x;
30257 20530 draw_screen_clip_rect_x2=255-curtain_x;
30258 20530 draw_screen_clip_rect_y1=0;
30259 20530 draw_screen_clip_rect_y2=223;
30260 //draw_screen(tmpscr);
30261 20530 }
30262 32050 }
30263
30264 32050 draw_screen(tmpscr);
30265 //this causes bugs
30266 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
30267 //so this is not necessary -DD
30268 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,false);
30269
30270 //Run Triforce Script
30271 32050 advanceframe(true);
30272 32050 ++f;
30273
2/2
✓ Branch 0 taken 31990 times.
✓ Branch 1 taken 60 times.
64100 }
30274 while
30275 (
30276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
30277
4/6
✓ Branch 0 taken 4380 times.
✓ Branch 1 taken 27670 times.
✓ Branch 2 taken 4380 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4380 times.
32050 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
30278
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4380 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4234 times.
✓ Branch 7 taken 146 times.
8760 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
30279 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
30280 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
30281 // value doesn't matter.
30282
2/4
✓ Branch 0 taken 4234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4380 times.
4380 || (replay_is_active() && f < 480) )
30283 ); // 800 may not be just right, but it works
30284
30285 60 action=none; FFCore.setHeroAction(none);
30286 60 holdclk=0;
30287 60 draw_screen_clip_rect_x1=0;
30288 60 draw_screen_clip_rect_x2=255;
30289 60 draw_screen_clip_rect_y1=0;
30290 60 draw_screen_clip_rect_y2=223;
30291 60 show_subscreen_items=true;
30292
30293 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
30294 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
30295
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 1 times.
60 if((itemsbuf[id2].flags & ITEM_FLAG1) && ( get_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
30296 {
30297 61 sdir=dir;
30298 61 dowarp(1,0); //side warp
30299 61 }
30300 else
30301 {
30302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
30303 }
30304 60 }
30305
30306 4551 void red_shift()
30307 {
30308 4551 int32_t tnum=176;
30309
30310 // set up the new palette
30311
2/2
✓ Branch 0 taken 145632 times.
✓ Branch 1 taken 4551 times.
150183 for(int32_t i=CSET(2); i < CSET(4); i++)
30312 {
30313 145632 int32_t r = (i-CSET(2)) << 1;
30314 145632 RAMpal[i+tnum].r = r;
30315 145632 RAMpal[i+tnum].g = r >> 3;
30316 145632 RAMpal[i+tnum].b = r >> 4;
30317 145632 }
30318
30319 // color scale the game screen
30320
2/2
✓ Branch 0 taken 764568 times.
✓ Branch 1 taken 4551 times.
769119 for(int32_t y=0; y<168; y++)
30321 {
30322
2/2
✓ Branch 0 taken 195729408 times.
✓ Branch 1 taken 764568 times.
196493976 for(int32_t x=0; x<256; x++)
30323 {
30324 195729408 int32_t c = framebuf->line[y+playing_field_offset][x];
30325
2/2
✓ Branch 0 taken 172435839 times.
✓ Branch 1 taken 23293569 times.
195729408 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30326
1/2
✓ Branch 0 taken 195729408 times.
✗ Branch 1 not taken.
195729408 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
30327 195729408 }
30328 764568 }
30329
30330 4551 refreshpal = true;
30331 4551 }
30332
30333
30334
30335 void setup_red_screen_old()
30336 {
30337 clear_bitmap(framebuf);
30338 rectfill(scrollbuf, 0, 0, 255, 167, 0);
30339
30340 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
30341
30342 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
30343
30344 putscr(scrollbuf, 0, 0, tmpscr);
30345 putscrdoors(scrollbuf,0,0,tmpscr);
30346 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30347 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
30348
30349 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
30350
30351 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
30352 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
30353 {
30354 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
30355 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
30356 }
30357
30358 if(!(msg_bg_display_buf->clip))
30359 {
30360 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30361 }
30362
30363 if(!(msg_portrait_display_buf->clip))
30364 {
30365 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30366 }
30367
30368 if(!(msg_txt_display_buf->clip))
30369 {
30370 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30371 }
30372
30373 if(!(pricesdisplaybuf->clip))
30374 {
30375 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
30376 }
30377
30378 //red shift
30379 // color scale the game screen
30380 for(int32_t y=0; y<168; y++)
30381 {
30382 for(int32_t x=0; x<256; x++)
30383 {
30384 int32_t c = framebuf->line[y+playing_field_offset][x];
30385 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30386 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
30387 }
30388 }
30389
30390 // Hero->draw(framebuf);
30391 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
30392
30393 clear_bitmap(framebuf);
30394
30395 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
30396 && tmpscr->layermap[3]==0
30397 && tmpscr->layermap[4]==0
30398 && tmpscr->layermap[5]==0
30399 && !overheadcombos(tmpscr)))
30400 {
30401 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
30402
30403 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
30404 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
30405 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
30406 {
30407 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
30408 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
30409 }
30410 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
30411 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
30412
30413 //do an AND masked blit for messages on top of layers
30414 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
30415 {
30416 BITMAP* subbmp = create_bitmap_ex(8,256,168);
30417 clear_bitmap(subbmp);
30418 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
30419 {
30420 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
30421 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
30422 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
30423 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
30424 }
30425 for(int32_t y=0; y<168; y++)
30426 {
30427 for(int32_t x=0; x<256; x++)
30428 {
30429 int32_t c1 = framebuf->line[y+playing_field_offset][x];
30430 int32_t c2 = subbmp->line[y][x];
30431 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
30432
30433 if(c1 && c3)
30434 {
30435 framebuf->line[y+playing_field_offset][x] = c3;
30436 }
30437 else if(c1 && c2)
30438 {
30439 framebuf->line[y+playing_field_offset][x] = c2;
30440 }
30441 }
30442 }
30443 destroy_bitmap(subbmp);
30444 }
30445
30446 //red shift
30447 // color scale the game screen
30448 for(int32_t y=0; y<168; y++)
30449 {
30450 for(int32_t x=0; x<256; x++)
30451 {
30452 int32_t c = framebuf->line[y+playing_field_offset][x];
30453 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30454 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
30455 }
30456 }
30457 }
30458
30459 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
30460
30461 // set up the new palette
30462 for(int32_t i=CSET(2); i < CSET(4); i++)
30463 {
30464 int32_t r = (i-CSET(2)) << 1;
30465 RAMpal[i].r = r;
30466 RAMpal[i].g = r >> 3;
30467 RAMpal[i].b = r >> 4;
30468 }
30469
30470 refreshpal = true;
30471 }
30472
30473
30474
30475 60 void slide_in_color(int32_t color)
30476 {
30477
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 60 times.
360 for(int32_t i=1; i<16; i+=3)
30478 {
30479 300 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
30480 300 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
30481 300 RAMpal[CSET(2)+i] = NESpal(color);
30482 300 }
30483
30484 60 refreshpal=true;
30485 60 }
30486
30487
30488 54 void HeroClass::heroDeathAnimation()
30489 {
30490 54 int32_t f=0;
30491 54 int32_t deathclk=0,deathfrm=0;
30492
30493 54 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
30494
30495 54 kill_sfx(); //call before the onDeath script.
30496
30497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!debug_enabled)
30498 {
30499 54 Paused=false;
30500 54 }
30501
30502 /*
30503 game->set_deaths(zc_min(game->get_deaths()+1,999));
30504 dir=down;
30505 music_stop();
30506
30507 attackclk=hclk=superman=0;
30508 scriptcoldet = 1;
30509
30510 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
30511
30512
30513
30514 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
30515 quakeclk=wavy=0;
30516
30517 //in original Z1, Hero marker vanishes at death.
30518 //code in subscr.cpp, put_passive_subscr checks the following value.
30519 //color 255 is a GUI color, so quest makers shouldn't be using this value.
30520 //Also, subscreen is static after death in Z1.
30521 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
30522 QMisc.colors.hero_dot = 255;
30523 //doesn't work
30524 //scrollbuf is tampered with by draw_screen()
30525 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
30526 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
30527 clear_bitmap(subscrbmp);
30528 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, false, sspUP);
30529 QMisc.colors.hero_dot = tmp_hero_dot;
30530 */
30531 54 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
30532 54 clear_bitmap(subscrbmp);
30533 //get rid off all sprites but Hero
30534 54 guys.clear();
30535 54 items.clear();
30536 54 Ewpns.clear();
30537 54 Lwpns.clear();
30538 54 Sitems.clear();
30539 54 chainlinks.clear();
30540 54 decorations.clear();
30541 54 Playing = false;
30542
30543
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
30544 54 dir=down;
30545 54 music_stop();
30546
30547 54 attackclk=hclk=superman=0;
30548 54 scriptcoldet = 1;
30549
30550
2/2
✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 54 times.
1782 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
30551
30552
30553
30554 54 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
30555 54 quakeclk=wavy=0;
30556
30557 //in original Z1, Hero marker vanishes at death.
30558 //code in subscr.cpp, put_passive_subscr checks the following value.
30559 //color 255 is a GUI color, so quest makers shouldn't be using this value.
30560 //Also, subscreen is static after death in Z1.
30561 54 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
30562 54 QMisc.colors.hero_dot = 255;
30563 //doesn't work
30564 //scrollbuf is tampered with by draw_screen()
30565 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
30566
30567 54 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
30568 //Don't forget passive subscreen scripts!
30569
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 1 times.
54 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
30570 {
30571 1 script_drawing_commands.Clear(); //We only want draws from this script
30572
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(DMaps[currdmap].passive_sub_script != 0)
30573 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
30574
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if (FFCore.waitdraw(ScriptType::PassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::PassiveSubscreen))
30575 {
30576 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
30577 FFCore.waitdraw(ScriptType::PassiveSubscreen) = false;
30578 }
30579 1 BITMAP* tmp = framebuf;
30580 1 framebuf = subscrbmp; //Hack; force draws to subscrbmp
30581 1 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
30582 1 framebuf = tmp;
30583 1 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
30584 1 }
30585 54 QMisc.colors.hero_dot = tmp_hero_dot;
30586 54 bool clearedit = false;
30587 54 do
30588 {
30589
2/2
✓ Branch 0 taken 13512 times.
✓ Branch 1 taken 5247 times.
18759 if(f<254)
30590 {
30591
2/2
✓ Branch 0 taken 11730 times.
✓ Branch 1 taken 1782 times.
13512 if(f<=32)
30592 {
30593 1782 hclk=(32-f);
30594 1782 }
30595
30596
4/4
✓ Branch 0 taken 10176 times.
✓ Branch 1 taken 3336 times.
✓ Branch 2 taken 6148 times.
✓ Branch 3 taken 4028 times.
13512 if(f>=62 && f<138)
30597 {
30598
5/5
✓ Branch 0 taken 3180 times.
✓ Branch 1 taken 212 times.
✓ Branch 2 taken 212 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 212 times.
4028 switch((f-62)%20)
30599 {
30600 case 0:
30601 212 dir=right;
30602 212 break;
30603
30604 case 5:
30605 212 dir=up;
30606 212 break;
30607
30608 case 10:
30609 212 dir=left;
30610 212 break;
30611
30612 case 15:
30613 212 dir=down;
30614 212 break;
30615 }
30616
30617 4028 herostep();
30618 4028 }
30619
30620
4/4
✓ Branch 0 taken 3180 times.
✓ Branch 1 taken 10332 times.
✓ Branch 2 taken 2438 times.
✓ Branch 3 taken 742 times.
13512 if(f>=194 && f<208)
30621 {
30622
2/2
✓ Branch 0 taken 689 times.
✓ Branch 1 taken 53 times.
742 if(f==194)
30623 {
30624 53 action=dying;
30625 53 FFCore.setHeroAction(dying);
30626 53 }
30627
30628 742 extend = 0;
30629 742 cs = wpnsbuf[spr_death].csets&15;
30630 742 tile = wpnsbuf[spr_death].tile;
30631
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
30632 {
30633 tile += deathfrm;
30634 f = 206;
30635 if(++deathclk >= wpnsbuf[spr_death].speed)
30636 {
30637 deathclk=0;
30638 if(++deathfrm >= wpnsbuf[spr_death].frames)
30639 {
30640 f = 208;
30641 deathfrm = 0;
30642 }
30643 }
30644 }
30645
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 392 times.
742 else if(BSZ)
30646 {
30647 350 tile += (f-194)/3;
30648 350 }
30649
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 112 times.
392 else if(f>=204)
30650 {
30651 112 ++tile;
30652 112 }
30653 742 }
30654
30655
2/2
✓ Branch 0 taken 13459 times.
✓ Branch 1 taken 53 times.
13512 if(f==208)
30656 {
30657
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 50 times.
53 if ( dontdraw < 2 ) { dontdraw = 1; }
30658 53 }
30659
2/2
✓ Branch 0 taken 10464 times.
✓ Branch 1 taken 3048 times.
13512 if(get_bit(quest_rules,qr_FADE))
30660 {
30661
2/2
✓ Branch 0 taken 7020 times.
✓ Branch 1 taken 3444 times.
10464 if(f < 170)
30662 {
30663
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 2510 times.
7020 if(f<60)
30664 {
30665 2510 draw_screen(tmpscr);
30666 //reuse our static subscreen
30667 2510 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
30668 2510 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30669 2510 }
30670
30671
2/2
✓ Branch 0 taken 6979 times.
✓ Branch 1 taken 41 times.
7020 if(f==60)
30672 {
30673 41 red_shift();
30674 41 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
30675 41 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
30676 41 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
30677
30678
2/2
✓ Branch 0 taken 10496 times.
✓ Branch 1 taken 41 times.
10537 for(int32_t q=0; q<PAL_SIZE; q++)
30679 {
30680 10496 trans_table2.data[0][q] = q;
30681 10496 trans_table2.data[q][q] = q;
30682 10496 }
30683 41 }
30684
30685
3/4
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 2510 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4510 times.
7020 if(f>=60 && f<=169)
30686 {
30687 4510 draw_screen(tmpscr);
30688 //reuse our static subscreen
30689 4510 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30690 4510 red_shift();
30691
30692 4510 }
30693
30694
3/4
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 5749 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1271 times.
7020 if(f>=139 && f<=169)//fade from red to black
30695 {
30696 1271 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
30697 1271 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
30698 1271 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
30699 1271 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
30700
30701
2/2
✓ Branch 0 taken 325376 times.
✓ Branch 1 taken 1271 times.
326647 for(int32_t q=0; q<PAL_SIZE; q++)
30702 {
30703 325376 trans_table2.data[0][q] = q;
30704 325376 trans_table2.data[q][q] = q;
30705 325376 }
30706
30707 1271 refreshpal=true;
30708 1271 }
30709 7020 }
30710 else //f>=170
30711 {
30712
2/2
✓ Branch 0 taken 3403 times.
✓ Branch 1 taken 41 times.
3444 if(f==170)//make Hero grayish
30713 {
30714 41 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
30715
30716
2/2
✓ Branch 0 taken 656 times.
✓ Branch 1 taken 41 times.
697 for(int32_t i=CSET(6); i < CSET(7); i++)
30717 {
30718 656 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
30719 656 RAMpal[i] = _RGB(g,g,g);
30720 656 }
30721
30722 41 refreshpal = true;
30723 41 }
30724
30725 //draw only hero. otherwise black layers might cover him.
30726 3444 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
30727 3444 draw(framebuf);
30728 3444 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30729 }
30730 10464 }
30731 else //!qr_FADE
30732 {
30733
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==58)
30734 {
30735
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 12 times.
1164 for(int32_t i = 0; i < 96; i++)
30736 1152 tmpscr->cset[i] = 3;
30737
30738
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30739
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
30740
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
30741 194 tmpscr2[j].cset[i] = 3;
30742 12 }
30743
30744
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==59)
30745 {
30746
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 12 times.
972 for(int32_t i = 96; i < 176; i++)
30747 960 tmpscr->cset[i] = 3;
30748
30749
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30750
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
30751
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
30752 162 tmpscr2[j].cset[i] = 3;
30753 12 }
30754
30755
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==60)
30756 {
30757
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 for(int32_t i=0; i<176; i++)
30758 {
30759 2112 tmpscr->cset[i] = 2;
30760 2112 }
30761
30762
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30763
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
30764
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
30765 354 tmpscr2[j].cset[i] = 2;
30766
30767
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
30768 {
30769 60 RAMpal[CSET(2)+i] = NESpal(0x17);
30770 60 RAMpal[CSET(2)+i+1] = NESpal(0x16);
30771 60 RAMpal[CSET(2)+i+2] = NESpal(0x26);
30772 60 }
30773
30774 12 refreshpal=true;
30775 12 }
30776
30777
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==139)
30778 12 slide_in_color(0x06);
30779
30780
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==149)
30781 12 slide_in_color(0x07);
30782
30783
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==159)
30784 12 slide_in_color(0x0F);
30785
30786
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==169)
30787 {
30788 12 slide_in_color(0x0F);
30789 12 slide_in_color(0x0F);
30790 12 }
30791
30792
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==170)
30793 {
30794
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
30795 {
30796 60 RAMpal[CSET(6)+i] = NESpal(0x10);
30797 60 RAMpal[CSET(6)+i+1] = NESpal(0x30);
30798 60 RAMpal[CSET(6)+i+2] = NESpal(0x00);
30799 60 refreshpal = true;
30800 60 }
30801 12 }
30802
30803
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 1020 times.
3048 if(f < 169)
30804 {
30805 2028 draw_screen(tmpscr);
30806 //reuse our static subscreen
30807 2028 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30808 2028 }
30809 else
30810 {
30811 //draw only hero. otherwise black layers might cover him.
30812 1020 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
30813 1020 draw(framebuf);
30814 1020 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30815 }
30816 }
30817 13512 }
30818
30819
2/2
✓ Branch 0 taken 5088 times.
✓ Branch 1 taken 159 times.
5247 else if(f<350)//draw 'GAME OVER' text
30820 {
30821
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5088 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5088 if(get_bit(quest_rules, qr_INSTANT_RESPAWN) && !get_bit(quest_rules, qr_INSTANT_CONTINUE))
30822 {
30823 Quit = qRELOAD;
30824 skipcont = 1;
30825 clear_bitmap(framebuf);
30826 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30827 }
30828
2/4
✓ Branch 0 taken 5088 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5088 times.
5088 else if(!get_bit(quest_rules, qr_INSTANT_RESPAWN) && get_bit(quest_rules, qr_INSTANT_CONTINUE))
30829 {
30830 Quit = qCONT;
30831 skipcont = 1;
30832 clear_bitmap(framebuf);
30833 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30834 }
30835 else
30836 {
30837 5088 clear_a5_bmp(rti_infolayer.bitmap);
30838 5088 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
30839 5088 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30840 5088 textout_ex(framebuf,get_zc_font(font_zfont),"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
30841 }
30842 5088 }
30843 else
30844 {
30845 159 clear_bitmap(framebuf);
30846 }
30847
30848 //SFX... put them all here
30849
4/4
✓ Branch 0 taken 18599 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 53 times.
18759 switch(f)
30850 {
30851 case 0:
30852 54 sfx(getHurtSFX(),pan(x.getInt()));
30853 54 break;
30854 //Death sound.
30855 case 60:
30856 53 sfx(WAV_SPIRAL);
30857 53 break;
30858 //Message sound.
30859 case 194:
30860 53 sfx(WAV_MSG);
30861 53 break;
30862 }
30863 //adv:
30864 18759 advanceframe(true);
30865 18759 ++f;
30866
2/2
✓ Branch 0 taken 18705 times.
✓ Branch 1 taken 54 times.
37518 }
30867
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 18706 times.
18759 while(f<353 && !Quit);
30868
30869 54 destroy_bitmap(subscrbmp);
30870 54 action=none; FFCore.setHeroAction(none);
30871
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 51 times.
54 if ( dontdraw < 2 ) { dontdraw=0; }
30872 54 }
30873
30874
30875 13 void HeroClass::ganon_intro()
30876 {
30877 /*
30878 ************************
30879 * GANON INTRO SEQUENCE *
30880 ************************
30881 -25 DOT updates
30882 -24 HERO in
30883 0 TRIFORCE overhead - code begins at this point (f == 0)
30884 47 GANON in
30885 58 LIGHT step
30886 68 LIGHT step
30887 78 LIGHT step
30888 255 TRIFORCE out
30889 256 TRIFORCE in
30890 270 TRIFORCE out
30891 271 GANON out, HERO face up
30892 */
30893 13 loaded_guys=true;
30894 13 loaditem();
30895
30896
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 9 times.
13 if(game->lvlitems[dlevel]&liBOSS)
30897 {
30898 4 return;
30899 }
30900
30901 9 dir=down;
30902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if ( !isSideViewHero() )
30903 {
30904 9 fall = 0; //Fix midair glitch on holding triforce. -Z
30905 9 fakefall = 0;
30906 9 z = 0;
30907 9 fakez = 0;
30908 9 }
30909 9 action=landhold2; FFCore.setHeroAction(landhold2);
30910 9 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
30911 //not good, as this only returns the highest level that Hero possesses. -DD
30912 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
30913
30914
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2169 times.
✓ Branch 2 taken 2169 times.
✓ Branch 3 taken 9 times.
2178 for(int32_t f=0; f<271 && !Quit; f++)
30915 {
30916
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
2169 if(f==47)
30917 {
30918 9 music_stop();
30919 9 stop_sfx(WAV_ROAR);
30920 9 sfx(WAV_GASP);
30921 9 sfx(WAV_GANON);
30922 9 int32_t Id=0;
30923
30924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 711 times.
711 for(int32_t i=0; i<eMAXGUYS; i++)
30925 {
30926
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 9 times.
711 if(guysbuf[i].flags2&eneflag_ganon)
30927 {
30928 9 Id=i;
30929 9 break;
30930 }
30931 702 }
30932
30933
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if(current_item(itype_ring))
30934 {
30935 8 addenemy(160,96,Id,0);
30936 8 }
30937 else
30938 {
30939 1 addenemy(80,32,Id,0);
30940 }
30941 9 }
30942
30943
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
2169 if(f==48)
30944 {
30945 9 lighting(true,true); // Hmm. -L
30946 9 f += 30;
30947 9 }
30948
30949 //NES Z1, the triforce vanishes for one frame in two cases
30950 //while still showing Hero's two-handed overhead sprite.
30951 //This should be a Quest Rule for NES Accuracy. -Z
30952
4/4
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2151 times.
2169 if(f==255 || f==270)
30953 {
30954 18 holditem=-1;
30955 18 }
30956
30957
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
2169 if(f==256)
30958 {
30959 9 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
30960 9 }
30961
30962 2169 draw_screen(tmpscr);
30963 2169 advanceframe(true);
30964
30965
1/2
✓ Branch 0 taken 2169 times.
✗ Branch 1 not taken.
2169 if(rSbtn())
30966 {
30967 conveyclk=3;
30968 int32_t tmp_subscr_clk = frame;
30969 dosubscr(&QMisc);
30970 newscr_clk += frame - tmp_subscr_clk;
30971 }
30972
30973 2169 }
30974
30975 9 action=none; FFCore.setHeroAction(none);
30976 9 dir=up;
30977
30978
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 7 times.
9 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
30979 2 jukebox(MAXMIDIS-1);
30980 else
30981 7 playLevelMusic();
30982
30983 9 currcset=DMaps[currdmap].color;
30984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (get_bit(quest_rules, qr_GANONINTRO) )
30985 {
30986 9 dointro();
30987 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
30988 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
30989 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
30990 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
30991 9 }
30992 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
30993 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
30994 //on a different DMap.
30995 //~ Otherwise, why is it here?! -Z
30996
30997
30998 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
30999 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
31000
31001 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
31002 //Users who use that dmap rule should put ganons room on its own DMap! -Z
31003 9 cont_sfx(WAV_ROAR);
31004 13 }
31005
31006 9 void HeroClass::win_game()
31007 {
31008
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 replay_step_comment("win_game");
31009 9 Playing=Paused=false;
31010 9 action=won; FFCore.setHeroAction(won);
31011 9 Quit=qWON;
31012 9 hclk=0;
31013 9 x = 136;
31014
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 y = (isdungeon() && currscr<128) ? 75 : 73;
31015 9 z = fakez = fall = fakefall = spins = 0;
31016 9 dir=left;
31017 9 }
31018
31019 14960 void HeroClass::reset_swordcharge()
31020 {
31021 14960 charging=spins=tapping=0;
31022 14960 }
31023
31024 47046 void HeroClass::reset_hookshot()
31025 {
31026
10/12
✓ Branch 0 taken 35579 times.
✓ Branch 1 taken 11467 times.
✓ Branch 2 taken 35572 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 35526 times.
✓ Branch 5 taken 46 times.
✓ Branch 6 taken 35521 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 35521 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 35521 times.
47046 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
31027 {
31028 35521 action=none; FFCore.setHeroAction(none);
31029 35521 }
31030
31031 47046 hookshot_frozen=false;
31032 47046 hookshot_used=false;
31033 47046 pull_hero=false;
31034 47046 hs_fix=false;
31035 47046 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
31036 47046 switch_hooked = false;
31037
2/2
✓ Branch 0 taken 47045 times.
✓ Branch 1 taken 1 times.
47046 if(switching_object)
31038 1 switching_object->switch_hooked = false;
31039 47046 switching_object = NULL;
31040 47046 hooked_combopos = -1;
31041 47046 switchhook_cost_item = -1;
31042 47046 hooked_layerbits = 0;
31043
2/2
✓ Branch 0 taken 329322 times.
✓ Branch 1 taken 47046 times.
376368 for(auto q = 0; q < 7; ++q)
31044 329322 hooked_undercombos[q] = -1;
31045 47046 Lwpns.del(Lwpns.idFirst(wHSHandle));
31046 47046 Lwpns.del(Lwpns.idFirst(wHookshot));
31047 47046 chainlinks.clear();
31048
2/2
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 44572 times.
47046 int32_t index=directItem>-1 ? directItem : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
31049 47046 hs_switcher = false;
31050
31051
2/2
✓ Branch 0 taken 39537 times.
✓ Branch 1 taken 7509 times.
47046 if(index>=0)
31052 {
31053 7509 stop_sfx(itemsbuf[index].usesound);
31054 7509 }
31055
31056 47046 hs_xdist=0;
31057 47046 hs_ydist=0;
31058 47046 }
31059
31060
31061 4325779 bool HeroClass::can_deploy_ladder()
31062 {
31063
2/2
✓ Branch 0 taken 1612499 times.
✓ Branch 1 taken 2713280 times.
6628812 bool ladderallowed = ((!get_bit(quest_rules,qr_LADDERANYWHERE) && tmpscr->flags&fLADDER) || isdungeon()
31064
4/4
✓ Branch 0 taken 1398077 times.
✓ Branch 1 taken 2303033 times.
✓ Branch 2 taken 545441 times.
✓ Branch 3 taken 1757592 times.
2713280 || (get_bit(quest_rules,qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
31065
8/10
✓ Branch 0 taken 1715915 times.
✓ Branch 1 taken 3597694 times.
✓ Branch 2 taken 1345466 times.
✓ Branch 3 taken 370449 times.
✓ Branch 4 taken 1345397 times.
✓ Branch 5 taken 69 times.
✓ Branch 6 taken 1345397 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1345397 times.
6659006 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
31066
2/2
✓ Branch 0 taken 1324717 times.
✓ Branch 1 taken 20680 times.
1345397 (!isSideViewHero() || on_sideview_solid_oldpos(x,y,old_x,old_y)));
31067 }
31068
31069 5602641 void HeroClass::reset_ladder()
31070 {
31071 5602641 ladderx=laddery=0;
31072 5602641 }
31073
31074 bool is_conveyor(int32_t type);
31075 int32_t get_conveyor(int32_t x, int32_t y);
31076
31077 6406142 void HeroClass::check_conveyor()
31078 {
31079 6406142 ++newconveyorclk;
31080
1/2
✓ Branch 0 taken 6406142 times.
✗ Branch 1 not taken.
6406142 if (newconveyorclk < 0) newconveyorclk = 0;
31081
31082
14/18
✓ Branch 0 taken 6406142 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6406142 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6405566 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 6405566 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6405566 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6402991 times.
✓ Branch 11 taken 2575 times.
✓ Branch 12 taken 6402369 times.
✓ Branch 13 taken 622 times.
✓ Branch 14 taken 6398460 times.
✓ Branch 15 taken 3909 times.
✓ Branch 16 taken 6398460 times.
✓ Branch 17 taken 3909 times.
6406142 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
31083 {
31084 7682 is_conveyor_stunned = 0;
31085 7682 return;
31086 }
31087
31088 6398460 WalkflagInfo info;
31089 int32_t xoff,yoff;
31090 6398460 zfix deltax(0), deltay(0);
31091 6398460 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
31092
2/2
✓ Branch 0 taken 2128043 times.
✓ Branch 1 taken 4270417 times.
6398460 if(cmbid < 0)
31093 {
31094
2/2
✓ Branch 0 taken 4269706 times.
✓ Branch 1 taken 711 times.
4270417 if (conveyclk <= 0) is_on_conveyor=false;
31095 4270417 return;
31096 }
31097 2128043 newcombo const* cmb = &combobuf[cmbid];
31098 2128043 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
31099 2128043 bool custom_spd = (cmb->usrflags&cflag2);
31100
2/4
✓ Branch 0 taken 2128043 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2128043 times.
✗ Branch 3 not taken.
2128043 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
31101 {
31102 2128043 int32_t ctype=cmb->type;
31103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2128043 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2128043 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
31104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2128043 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2128043 if(custom_spd && (newconveyorclk % rate)) return;
31105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2128043 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2128043 if((cmb->usrflags&cflag5) && HasHeavyBoots())
31106 return;
31107 2128043 is_on_conveyor=false;
31108 2128043 is_conveyor_stunned=0;
31109
31110 2128043 deltax=combo_class_buf[ctype].conveyor_x_speed;
31111 2128043 deltay=combo_class_buf[ctype].conveyor_y_speed;
31112
31113
3/4
✓ Branch 0 taken 1735 times.
✓ Branch 1 taken 2126308 times.
✓ Branch 2 taken 1735 times.
✗ Branch 3 not taken.
2128043 if (is_conveyor(ctype) && custom_spd)
31114 {
31115 deltax = zslongToFix(cmb->attributes[0]);
31116 deltay = zslongToFix(cmb->attributes[1]);
31117 }
31118
31119
8/8
✓ Branch 0 taken 2127258 times.
✓ Branch 1 taken 785 times.
✓ Branch 2 taken 2126308 times.
✓ Branch 3 taken 950 times.
✓ Branch 4 taken 83337 times.
✓ Branch 5 taken 2042971 times.
✓ Branch 6 taken 41416 times.
✓ Branch 7 taken 41921 times.
2128043 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(x,y,old_x,old_y)))
31120 {
31121 41921 cmbid = MAPCOMBO(x+8,y+16);
31122 41921 cmb = &combobuf[cmbid];
31123 41921 custom_spd = cmb->usrflags&cflag2;
31124 41921 ctype=(cmb->type);
31125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41921 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
41921 rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
31126 41921 deltax=combo_class_buf[ctype].conveyor_x_speed;
31127 41921 deltay=combo_class_buf[ctype].conveyor_y_speed;
31128
2/4
✓ Branch 0 taken 41921 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41921 times.
✗ Branch 3 not taken.
41921 if ((deltax != 0 || deltay != 0) && custom_spd)
31129 {
31130 deltax = zslongToFix(cmb->attributes[0]);
31131 deltay = zslongToFix(cmb->attributes[1]);
31132 }
31133 41921 }
31134
31135
4/4
✓ Branch 0 taken 2127258 times.
✓ Branch 1 taken 785 times.
✓ Branch 2 taken 950 times.
✓ Branch 3 taken 2126308 times.
2128043 if(deltax!=0||deltay!=0)
31136 {
31137 1735 is_on_conveyor=true;
31138 1735 }
31139 2126308 else return;
31140
31141
1/2
✓ Branch 0 taken 1735 times.
✗ Branch 1 not taken.
1735 bool forcewalk = (cmb->usrflags&cflag6) && get_bit(quest_rules,qr_NEW_HERO_MOVEMENT2);
31142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1735 times.
1735 if(forcewalk)
31143 {
31144 is_conveyor_stunned = rate;
31145 if(cmb->usrflags&cflag3)
31146 {
31147 if(abs(deltax) > abs(deltay))
31148 dir = (deltax > 0) ? right : left;
31149 else dir = (deltay > 0) ? down : up;
31150 }
31151 convey_forcex = deltax;
31152 convey_forcey = deltay;
31153 }
31154 else
31155 {
31156 1735 bool movedx = false, movedy = false;
31157
1/2
✓ Branch 0 taken 1735 times.
✗ Branch 1 not taken.
1735 if(cmb->usrflags&cflag4) //Smart corners
31158 {
31159 if(deltay<0)
31160 {
31161 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
31162 execute(info);
31163
31164 if(!info.isUnwalkable())
31165 {
31166 movedy = true;
31167 zfix step(0);
31168
31169 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31170 {
31171 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
31172 {
31173 yoff=int32_t(y-step)&7;
31174
31175 if(!yoff) break;
31176
31177 step++;
31178 }
31179 }
31180 else
31181 {
31182 step=abs(deltay);
31183 }
31184
31185 y=y-step;
31186 hs_starty-=step.getInt();
31187
31188 for(int32_t j=0; j<chainlinks.Count(); j++)
31189 {
31190 chainlinks.spr(j)->y-=step;
31191 }
31192
31193 if(Lwpns.idFirst(wHookshot)>-1)
31194 {
31195 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
31196 }
31197
31198 if(Lwpns.idFirst(wHSHandle)>-1)
31199 {
31200 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
31201 }
31202 }
31203 }
31204 else if(deltay>0)
31205 {
31206 info = walkflag(x,y+15+2,2,down);
31207 execute(info);
31208
31209 if(!info.isUnwalkable())
31210 {
31211 movedy = true;
31212 zfix step(0);
31213
31214 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31215 {
31216 while(step<abs(deltay))
31217 {
31218 yoff=int32_t(y+step)&7;
31219
31220 if(!yoff) break;
31221
31222 step++;
31223 }
31224 }
31225 else
31226 {
31227 step=abs(deltay);
31228 }
31229
31230 y=y+step;
31231 hs_starty+=step.getInt();
31232
31233 for(int32_t j=0; j<chainlinks.Count(); j++)
31234 {
31235 chainlinks.spr(j)->y+=step;
31236 }
31237
31238 if(Lwpns.idFirst(wHookshot)>-1)
31239 {
31240 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
31241 }
31242
31243 if(Lwpns.idFirst(wHSHandle)>-1)
31244 {
31245 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
31246 }
31247 }
31248 }
31249
31250 if(deltax<0)
31251 {
31252 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
31253 execute(info);
31254
31255 if(!info.isUnwalkable())
31256 {
31257 movedx = true;
31258 zfix step(0);
31259
31260 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31261 {
31262 while(step<abs(deltax))
31263 {
31264 xoff=int32_t(x-step)&7;
31265
31266 if(!xoff) break;
31267
31268 step++;
31269 }
31270 }
31271 else
31272 {
31273 step=abs(deltax);
31274 }
31275
31276 x=x-step;
31277 hs_startx-=step.getInt();
31278
31279 for(int32_t j=0; j<chainlinks.Count(); j++)
31280 {
31281 chainlinks.spr(j)->x-=step;
31282 }
31283
31284 if(Lwpns.idFirst(wHookshot)>-1)
31285 {
31286 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
31287 }
31288
31289 if(Lwpns.idFirst(wHSHandle)>-1)
31290 {
31291 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
31292 }
31293 }
31294 }
31295 else if(deltax>0)
31296 {
31297 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
31298 execute(info);
31299
31300 if(!info.isUnwalkable())
31301 {
31302 movedx = true;
31303 zfix step(0);
31304
31305 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31306 {
31307 while(step<abs(deltax))
31308 {
31309 xoff=int32_t(x+step)&7;
31310
31311 if(!xoff) break;
31312
31313 step++;
31314 }
31315 }
31316 else
31317 {
31318 step=abs(deltax);
31319 }
31320
31321 x=x+step;
31322 hs_startx+=step.getInt();
31323
31324 for(int32_t j=0; j<chainlinks.Count(); j++)
31325 {
31326 chainlinks.spr(j)->x+=step;
31327 }
31328
31329 if(Lwpns.idFirst(wHookshot)>-1)
31330 {
31331 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
31332 }
31333
31334 if(Lwpns.idFirst(wHSHandle)>-1)
31335 {
31336 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
31337 }
31338 }
31339 }
31340 if(deltax && !movedx)
31341 y = COMBOY(pos);
31342 if(deltay && !movedy)
31343 x = COMBOX(pos);
31344 }
31345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1735 times.
1735 if(!movedy)
31346 {
31347
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 1525 times.
1735 if(deltay<0)
31348 {
31349 210 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
31350 210 execute(info);
31351
31352
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 184 times.
210 if(!info.isUnwalkable())
31353 {
31354 184 movedy = true;
31355 184 zfix step(0);
31356
31357
10/12
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 118 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 55 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 6 times.
184 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31358 {
31359
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 11 times.
16 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
31360 {
31361 11 yoff=int32_t(y-step)&7;
31362
31363
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if(!yoff) break;
31364
31365 10 step++;
31366 }
31367 6 }
31368 else
31369 {
31370 178 step=abs(deltay);
31371 }
31372
31373 184 y=y-step;
31374 184 hs_starty-=step.getInt();
31375
31376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 184 times.
184 for(int32_t j=0; j<chainlinks.Count(); j++)
31377 {
31378 chainlinks.spr(j)->y-=step;
31379 }
31380
31381
1/2
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
184 if(Lwpns.idFirst(wHookshot)>-1)
31382 {
31383 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
31384 }
31385
31386
1/2
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
184 if(Lwpns.idFirst(wHSHandle)>-1)
31387 {
31388 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
31389 }
31390 184 }
31391 26 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
31392 210 }
31393
2/2
✓ Branch 0 taken 785 times.
✓ Branch 1 taken 740 times.
1525 else if(deltay>0)
31394 {
31395 740 info = walkflag(x,y+15+2,2,down);
31396 740 execute(info);
31397
31398
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 488 times.
740 if(!info.isUnwalkable())
31399 {
31400 488 movedy = true;
31401 488 zfix step(0);
31402
31403
9/12
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 167 times.
✓ Branch 3 taken 321 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 62 times.
488 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31404 {
31405
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 104 times.
144 while(step<abs(deltay))
31406 {
31407 104 yoff=int32_t(y+step)&7;
31408
31409
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 82 times.
104 if(!yoff) break;
31410
31411 82 step++;
31412 }
31413 62 }
31414 else
31415 {
31416 426 step=abs(deltay);
31417 }
31418
31419 488 y=y+step;
31420 488 hs_starty+=step.getInt();
31421
31422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 488 times.
488 for(int32_t j=0; j<chainlinks.Count(); j++)
31423 {
31424 chainlinks.spr(j)->y+=step;
31425 }
31426
31427
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(Lwpns.idFirst(wHookshot)>-1)
31428 {
31429 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
31430 }
31431
31432
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(Lwpns.idFirst(wHSHandle)>-1)
31433 {
31434 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
31435 }
31436 488 }
31437 252 else checkdamagecombos(x,y+15);
31438 740 }
31439 1735 }
31440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1735 times.
1735 if(!movedx)
31441 {
31442
2/2
✓ Branch 0 taken 518 times.
✓ Branch 1 taken 1217 times.
1735 if(deltax<0)
31443 {
31444 518 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
31445 518 execute(info);
31446
31447
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 352 times.
518 if(!info.isUnwalkable())
31448 {
31449 352 movedx = true;
31450 352 zfix step(0);
31451
31452
9/12
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 296 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 38 times.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 18 times.
352 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31453 {
31454
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 while(step<abs(deltax))
31455 {
31456 32 xoff=int32_t(x-step)&7;
31457
31458
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 5 times.
32 if(!xoff) break;
31459
31460 27 step++;
31461 }
31462 18 }
31463 else
31464 {
31465 334 step=abs(deltax);
31466 }
31467
31468 352 x=x-step;
31469 352 hs_startx-=step.getInt();
31470
31471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 352 times.
352 for(int32_t j=0; j<chainlinks.Count(); j++)
31472 {
31473 chainlinks.spr(j)->x-=step;
31474 }
31475
31476
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(Lwpns.idFirst(wHookshot)>-1)
31477 {
31478 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
31479 }
31480
31481
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(Lwpns.idFirst(wHSHandle)>-1)
31482 {
31483 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
31484 }
31485 352 }
31486 166 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
31487 518 }
31488
2/2
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 267 times.
1217 else if(deltax>0)
31489 {
31490 267 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
31491 267 execute(info);
31492
31493
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 264 times.
267 if(!info.isUnwalkable())
31494 {
31495 264 movedx = true;
31496 264 zfix step(0);
31497
31498
9/12
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 208 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 25 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 25 times.
264 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31499 {
31500
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 47 times.
67 while(step<abs(deltax))
31501 {
31502 47 xoff=int32_t(x+step)&7;
31503
31504
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5 times.
47 if(!xoff) break;
31505
31506 42 step++;
31507 }
31508 25 }
31509 else
31510 {
31511 239 step=abs(deltax);
31512 }
31513
31514 264 x=x+step;
31515 264 hs_startx+=step.getInt();
31516
31517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 for(int32_t j=0; j<chainlinks.Count(); j++)
31518 {
31519 chainlinks.spr(j)->x+=step;
31520 }
31521
31522
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(Lwpns.idFirst(wHookshot)>-1)
31523 {
31524 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
31525 }
31526
31527
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(Lwpns.idFirst(wHSHandle)>-1)
31528 {
31529 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
31530 }
31531 264 }
31532 3 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
31533 267 }
31534 1735 }
31535
4/4
✓ Branch 0 taken 1119 times.
✓ Branch 1 taken 616 times.
✓ Branch 2 taken 672 times.
✓ Branch 3 taken 447 times.
1735 if(movedx || movedy)
31536 {
31537
1/2
✓ Branch 0 taken 1288 times.
✗ Branch 1 not taken.
1288 if(cmb->usrflags&cflag1)
31538 is_conveyor_stunned = rate;
31539
1/2
✓ Branch 0 taken 1288 times.
✗ Branch 1 not taken.
1288 if(cmb->usrflags&cflag3)
31540 {
31541 if(abs(deltax) > abs(deltay))
31542 dir = (deltax > 0) ? right : left;
31543 else dir = (deltay > 0) ? down : up;
31544 }
31545 1288 }
31546 }
31547 1735 }
31548 6406142 }
31549
31550 void HeroClass::setDivineProtectionShieldClk(int32_t newclk)
31551 {
31552 DivineProtectionShieldClk=newclk;
31553
31554 if(decorations.idCount(dDIVINEPROTECTIONSHIELD)==0)
31555 {
31556 decoration *dec;
31557 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
31558 decorations.spr(decorations.Count()-1)->misc=0;
31559 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
31560 dec=(decoration *)decorations.spr(decorations.Count()-1);
31561 decorations.spr(decorations.Count()-1)->misc=1;
31562 }
31563 }
31564
31565 13468 int32_t HeroClass::getDivineProtectionShieldClk()
31566 {
31567 13468 return DivineProtectionShieldClk;
31568 }
31569
31570 21 int32_t HeroClass::getHoverClk()
31571 {
31572 21 return hoverclk;
31573 }
31574
31575 7238712 int32_t HeroClass::getHoldClk()
31576 {
31577 7238712 return holdclk;
31578 }
31579
31580 4261452 int32_t HeroClass::getLastLensID(){
31581 4261452 return last_lens_id;
31582 }
31583
31584 209 void HeroClass::setLastLensID(int32_t p_item){
31585 209 last_lens_id = p_item;
31586 209 }
31587
31588 53287476 bool HeroClass::getOnSideviewLadder()
31589 {
31590 53287476 return on_sideview_ladder;
31591 }
31592
31593 23 void HeroClass::setOnSideviewLadder(bool val)
31594 {
31595
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(val)
31596 {
31597 fall = fakefall = hoverclk = jumping = 0;
31598 hoverflags = 0;
31599 inair = false;
31600 }
31601 23 on_sideview_ladder = val;
31602 23 }
31603
31604 1910146 bool HeroClass::canSideviewLadder(bool down)
31605 {
31606
2/2
✓ Branch 0 taken 1876243 times.
✓ Branch 1 taken 33903 times.
1910146 if(!isSideViewHero()) return false;
31607
2/2
✓ Branch 0 taken 20697 times.
✓ Branch 1 taken 13206 times.
33903 if(jumping < 0) return false;
31608
3/4
✓ Branch 0 taken 8519 times.
✓ Branch 1 taken 12178 times.
✓ Branch 2 taken 8519 times.
✗ Branch 3 not taken.
20697 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
31609 {
31610 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
31611 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
31612 }
31613 //Are you presently able to climb a sideview ladder?
31614 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
31615 //y+0 checks your top-half for large hitbox; y+8 for small
31616 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
31617 //y+16 check is for going down onto a ladder you are standing on.
31618
1/2
✓ Branch 0 taken 20697 times.
✗ Branch 1 not taken.
41394 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
31619
2/4
✓ Branch 0 taken 20697 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20697 times.
✗ Branch 3 not taken.
20697 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
31620
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20697 times.
✓ Branch 2 taken 12178 times.
✓ Branch 3 taken 8519 times.
✓ Branch 4 taken 8519 times.
✗ Branch 5 not taken.
29216 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
31621 1910146 }
31622
31623 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
31624 {
31625 if(!isSideViewHero()) return false;
31626 if(jumping < 0) return false;
31627 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
31628 {
31629 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
31630 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
31631 }
31632 //Are you presently able to climb a sideview ladder?
31633 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
31634 //y+0 checks your top-half for large hitbox; y+8 for small
31635 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
31636 //y+16 check is for going down onto a ladder you are standing on.
31637 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
31638 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
31639 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
31640 }
31641
31642 3957789 void HeroClass::execute(HeroClass::WalkflagInfo info)
31643 {
31644 3957789 int32_t flags = info.getFlags();
31645
31646
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 3957141 times.
3957789 if(flags & WalkflagInfo::CLEARILSWIM)
31647 648 ilswim =false;
31648
2/2
✓ Branch 0 taken 3956345 times.
✓ Branch 1 taken 796 times.
3957141 else if(flags & WalkflagInfo::SETILSWIM)
31649 796 ilswim = true;
31650
31651
1/2
✓ Branch 0 taken 3957789 times.
✗ Branch 1 not taken.
3957789 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
31652 {
31653 charging = 0;
31654 attackclk = 0;
31655 }
31656
31657
1/2
✓ Branch 0 taken 3957789 times.
✗ Branch 1 not taken.
3957789 if(flags & WalkflagInfo::SETDIR)
31658 {
31659 dir = info.getDir();
31660 }
31661
31662
2/2
✓ Branch 0 taken 3957212 times.
✓ Branch 1 taken 577 times.
3957789 if(flags & WalkflagInfo::SETHOPCLK)
31663 {
31664 577 hopclk = info.getHopClk();
31665 577 }
31666
31667
2/2
✓ Branch 0 taken 3957291 times.
✓ Branch 1 taken 498 times.
3957789 if(flags & WalkflagInfo::SETHOPDIR)
31668 {
31669 498 hopdir = info.getHopDir();
31670 498 }
31671
31672 3957789 }
31673
31674 8572442 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
31675 {
31676 8572442 HeroClass::WalkflagInfo ret;
31677 8572442 ret.newhopclk = newhopclk;
31678 8572442 ret.newdir = newdir;
31679
2/2
✓ Branch 0 taken 7102969 times.
✓ Branch 1 taken 1469473 times.
8572442 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
31680
31681 8572442 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
31682 8572442 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
31683 8572442 ret.flags = flags1 | flags2;
31684 8572442 return ret;
31685 }
31686
31687 48864 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
31688 {
31689 48864 HeroClass::WalkflagInfo ret;
31690 48864 ret.newhopclk = newhopclk;
31691 48864 ret.newdir = newdir;
31692
1/2
✓ Branch 0 taken 48864 times.
✗ Branch 1 not taken.
48864 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
31693
31694 48864 ret.flags = flags & other.flags;
31695 48864 return ret;
31696 }
31697
31698 48864 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
31699 {
31700 48864 HeroClass::WalkflagInfo ret;
31701 48864 ret.newhopclk = newhopclk;
31702 48864 ret.newdir = newdir;
31703 48864 ret.newhopdir = newhopdir;
31704
31705 48864 ret.flags = flags ^ UNWALKABLE;
31706 48864 return ret;
31707 }
31708
31709 void HeroClass::explode(int32_t type)
31710 {
31711 static int32_t tempx, tempy;
31712 static byte herotilebuf[256];
31713 int32_t ltile=0;
31714 int32_t lflip=0;
31715 bool shieldModify=true;
31716 unpack_tile(newtilebuf, tile, flip, true);
31717 memcpy(herotilebuf, unpackbuf, 256);
31718 tempx=Hero.getX();
31719 tempy=Hero.getY();
31720 for(int32_t i=0; i<16; ++i)
31721 {
31722 for(int32_t j=0; j<16; ++j)
31723 {
31724 if(herotilebuf[i*16+j])
31725 {
31726 if(type==0) // Twilight
31727 {
31728 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
31729 int32_t k=particles.Count()-1;
31730 particle *p = (particles.at(k));
31731 p->step=3;
31732 }
31733 else if(type ==1) // Sands of Hours
31734 {
31735 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
31736 int32_t k=particles.Count()-1;
31737 particle *p = (particles.at(k));
31738 p->step=4;
31739
31740 if(zc_oldrand()%10 < 2)
31741 {
31742 p->color=1;
31743 p->cset=0;
31744 }
31745 }
31746 else
31747 {
31748 particles.add(new pDivineEscapeDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
31749
31750 int32_t k=particles.Count()-1;
31751 particle *p = (particles.at(k));
31752 p->angular=true;
31753 p->angle=zc_oldrand();
31754 p->step=(((double)j)/8);
31755 p->yofs=Hero.getYOfs();
31756 }
31757 }
31758 }
31759 }
31760 }
31761
31762 984 void HeroClass::SetSwim()
31763 {
31764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 984 times.
984 if (CanSideSwim())
31765 {
31766 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
31767 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
31768 if (get_bit(quest_rules,qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
31769 }
31770 984 else {action=swimming; FFCore.setHeroAction(swimming);}
31771 984 }
31772
31773 60443 void HeroClass::SetAttack()
31774 {
31775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60443 times.
60443 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
31776 60443 else {action=attacking; FFCore.setHeroAction(attacking);}
31777 60443 }
31778
31779 53003934 bool HeroClass::IsSideSwim()
31780 {
31781
6/12
✓ Branch 0 taken 53003934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53003934 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53003934 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 53003934 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 53003934 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 53003934 times.
53003934 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
31782 }
31783
31784 1532064 bool HeroClass::CanSideSwim()
31785 {
31786
1/2
✓ Branch 0 taken 1532064 times.
✗ Branch 1 not taken.
1532064 return (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM));
31787 }
31788
31789 5062550 int32_t HeroClass::getTileModifier()
31790 {
31791 5062550 return item_tile_mod() + bunny_tile_mod();
31792 }
31793 void HeroClass::setImmortal(int32_t nimmortal)
31794 {
31795 immortal = nimmortal;
31796 }
31797 void HeroClass::kill(bool bypassFairy)
31798 {
31799 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
31800 }
31801 12828866 bool HeroClass::sideview_mode() const
31802 {
31803
3/4
✓ Branch 0 taken 501383 times.
✓ Branch 1 taken 12327483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 501383 times.
12828866 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
31804 }
31805 2424 bool HeroClass::is_unpushable() const
31806 {
31807 2424 return toogam;
31808 }
31809